A customer has recently had their Office software upgraded to Office 365 and now the bespoke software they use will not send e-mails, instead they get the error "Cannot create ActiveX component".
I have looked at some of the other cases online where this error is mentioned, but I have not found any that seem to fit this situation.
The bespoke software is created using Visual Basic in Visual Studio 2013, with a Target CPU of x86 and a Target Framework of .NET Framework 4. The machine that the software is on is running Windows 10 Pro 10.0.19045 Build 19045. The version of Outlook is 2409, Build 18025.20140 Click to Run. The version of the Microsoft.Office.Interop.Outlook.dll is 14.0.4760.1000 (Size 950 kb).
Outlook states that the "Microsoft VBA for Outlook Addin" is Inactive, if that is relevant.
Could anyone suggest ways that I could try to solve this problem?
I have looked on their system and tried:- Putting the Microsoft.Office.Interop.Outlook.dll file into the folder which holds the EXE file. Putting the Microsoft.Office.Interop.Outlook.dll file into the System32 folder. Putting the Microsoft.Office.Interop.Outlook.dll file into the SysWow64 folder.
I have looked at HKEY_CLASSES_ROOT\Outlook.Application.16, right clicked and looked at the Permissions - Administrators have the Full Control box ticked but Users do not.
I have looked at some of the other cases online where this error is mentioned, but I have not found any that seem to fit this situation.
Private Sub btnemail_Click(sender As System.Object, e As System.EventArgs) Handles btnemail.Click
Dim emailadd As String = ""
Dim cownt As Integer = 0
Using conn As New SqlConnection
Try
conn.ConnectionString = ConnectionString
Dim command2 As New SqlCommand("CustSelEmail", conn)
command2.CommandType = CommandType.StoredProcedure
command2.Parameters.Add(New SqlParameter("@Nick", NickNom))
Dim SQLParamOP As New SqlParameter("@Workd", "")
SQLParamOP.Direction = ParameterDirection.Output
command2.Parameters.Add(SQLParamOP)
conn.Open()
Dim reader As SqlDataReader = command2.ExecuteReader
While reader.Read
emailadd = reader(0).ToString
End While
conn.Close()
If emailadd = "" Then
MsgBox("There is no email address for this Customer account")
Exit Sub
End If
If My.Computer.FileSystem.FileExists("Filename" & NickNom & ".pdf") = True Then
My.Computer.FileSystem.DeleteFile("Filename" & NickNom & ".pdf", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
End If
crreportdocument.ExportToDisk(ExportFormatType.PortableDocFormat, "Filename" & NickNom & ".pdf")
Dim myolapp As Object
myolapp = GetObject("Outlook.Application")
Dim mailItem As Outlook.MailItem = myolapp.CreateItem(Outlook.OlItemType.olMailItem)
mailItem.Subject = "Company Invoice"
mailItem.To = emailadd
mailItem.Body = "Invoice is attached."
mailItem.Importance = Outlook.OlImportance.olImportanceNormal
mailItem.Attachments.Add("Filename" & NickNom & ".pdf", Outlook.OlAttachmentType.olByValue, 1, "Filename" & NickNom & ".pdf")
mailItem.Display(True) 'Shows the email on screen
mailItem = Nothing
myolapp = Nothing
Catch ex As Exception
If ex.GetBaseException.Message = "Cannot create ActiveX component." And cownt < 25 Then 'For Outlook 2010
cownt = cownt + 1 'To stop infinite loop when genuine error
GoTo Create
End If
MsgBox(ex.GetBaseException.Message, MsgBoxStyle.OkOnly, " e-mail")
Error_Log(modname, cboCustFrom.Text & " - " & cboCustTo.Text, ex, "e-mail")
Finally
conn.Close()
End Try
End Using
End Sub