I was informed an AppV5 application was getting the following error message:
1 2 3 4 5 |
Microsoft Outlook No Microsoft Outlook profiles have been created. In Microsoft Windows, click the Start button, and then click Control Panel. Click User Accounts, and then click Mail. Click Show Profiles, and then click Add. OK |
So what’s going on here?
The application is trying to create an email message and needs to activate Outlook to add the attachment. This error can be worked around by launching Outlook *first*, which creates our profile, but I would prefer to not launch programs to use resources in the background if it can be avoided.
What I’d like to do is silently create our Outlook profile and then continue launching the application. I didn’t find a particularly good solution for this, but I did eventually stumble across one with some minor modifications to meet my needs:
1 2 3 4 5 |
$MsOutlook = New-Object -ComObject Outlook.Application $Namespace = $MsOutlook.GetNamespace("MAPI") $Folder = $Namespace.GetDefaultFolder("olFolderInbox") $Explorer = $Folder.GetExplorer() $MsOutlook.quit() |
Or via cmd.exe:
1 |
powershell.exe -executionPolicy byPass -command "&{ $MsOutlook = New-Object -ComObject Outlook.Application; $Namespace = $MsOutlook.GetNamespace(\"MAPI\"); $Folder = $Namespace.GetDefaultFolder(\"olFolderInbox\"); $Explorer = $Folder.GetExplorer(); $MsOutlook.quit() }" |
This powershell script will launch launch Outlook into the ‘Inbox’ and terminate. Since it’s done through ’embedded’ commands the only thing you may see is a brief blip of Outlook with the ’embedded’ icon in the taskbar.