We are invoking Outlook Application and Mail COM component to fill in and display an email for the user. However, in some cases this results in an exception shown below. Invoking Outlook through COM works just fine in a local install of Office prior to the upgrade from out application code. For simplicity, we can replicate the same behavior in PowerShell.
When using Office 365, HKEY_USERS
is being called rather than \HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID{0006F023-0000-0000-C000-000000000046}
. Microsoft Support has stated Office 365 will never place a key in the User Hive. However, PowerShell is observed making the same call when calling to create an Outlook object. Why is this happening? What does Microsoft expect as required to use 'Create Mail Item' for Outlook.
Load PowerShell ISE using an non-admin account. Works fine from admin accounts.
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "recipient@test.com"
$Mail.Subject = "subject"
$Mail.Body = "testing"
$Mail.Display()
If you execute above block, you will receive the following error (screenshot) calling the same registry in question. ProcMon verifies User Hive is being called.
Exception:
DataOne.MailItemCreationException: There was a problem creating the Outlook Mail Item
at DataOne.OutlookProcessor.DisplayMessage(IEnumerable`1 attachments, String body, String subject)
at DataOne.OutlookdProcessor.<DisplayDialog>b__3_0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Powershell:
New-Object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error:
80040153 Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE)).
User contributions licensed under CC BY-SA 3.0