I am using vb to send emails through outlook. Currently we have a mix of outlook versions at our office:
2010 and 2013 with a mix of 32 bit and 64 bit (a mess, I know). The code I have works well for Outlook 2010:
Private Sub btnEmail_Click(sender As System.Object, e As System.EventArgs) Handles btnEmail.Click
CreateMailItem()
End Sub
Private Sub CreateMailItem()
Dim application As New Application
Dim mailItem As Microsoft.
Office.Interop.Outlook.MailItem = CType(application.CreateItem( _
Microsoft.
Office.Interop.Outlook.OlItemType.olMailItem), Microsoft.
Office.Interop.Outlook.MailItem) 'Me.a(Microsoft.
Office.Interop.Outlook.OlItemType.olMailItem)
mailItem.Subject = "This is the subject"
mailItem.To = "
[email protected]"
mailItem.Body = "This is the message."
mailItem.Importance = Microsoft.
Office.Interop.Outlook.OlImportance.olImportanceLow
mailItem.Display(True)
End Sub
However, I cannot get this to work for 2013. I have referenced the version 15 dll for 2013 and it seems to be backward compatible, but when I try to use the above code for 2013 (it is 64 bit) it says it cannot start Microsoft Outlook. A program error has occured. This is happening on the application Dim statement line. I have tried googling around but there doesn't seem to be much out there referencing 2013 but I feel that the problem here probably has more to do with 64 bit than the software version. Thank you for any suggestions!