
Error 429 only if Outlook is already open when try to automate an email

Hugh Self Taught
101
Reputation points
Good day Gurus of .Net
Since I started trying to get my app to be option strict compliant, I've suddenly started getting error 429 Unable to create active x component BUT only when Outlook is already open. I have the following code to get an instance of Outlook. The line "oOutlook = Activator.CreateInstance(outlookType)" returns the following error. Any ideas on how I rectify this will be greatly appreciated
Dim procs() As Process = Process.GetProcessesByName("Outlook")
If procs.Count > 0 Then
Dim outlookType As Type = Type.GetTypeFromProgID("Outlook.Application")
oOutlook = Activator.CreateInstance(outlookType)
Else
'oOutlook = New Outlook.Application()
oOutlook = New Microsoft.Office.Interop.Outlook.Application()
End If
oNameSpace = oOutlook.Session
Dim oFolder As Outlook.MAPIFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Microsoft 365 and Office | Development | Other

4,383 questions
Outlook | Windows | Classic Outlook for Windows | For business
9,737 questions
Developer technologies | VB
2,892 questions
Sign in to answer