I have a vb.net script that sends automatic emails from Outlook. It currently works in the Office 2010 Suite. I upgraded my environments to 2013 and now it is not working. What I'm doing isn't complicated. All I want to do is grab a .pdf and attache it to an email. Then add the recipients and send the email. The place where it crashes is the actual sending of the email. It throws this execption
System.Runtime.InteropServices.COMEception occurred in Microsoft.VisualBasic.dll
Additional information: Operation aborted (Execption from HRESULT: 0x80004004 (E_ABORT))
I'm thinking because I upgraded environments something isn't referenced correctly. But I can't seem to find a fix. Below is my code, any help would be greatly appreciated! Thanks in advanced.
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Sub main()
sendEmail()
End Sub
Public Sub sendEmail()
Dim ol As Object
Dim mail AS Object
ol = CreateObject("Outlook.Application")
mail = ol.CreateItem(0)
mail.To = "email@example.com"
mail.Subject = "Subject Line"
mail.Body = "Body text"
mail.Attachments.Add("path\to\attachment.pdf")
mail.Send() 'crashes on this line
mail = Nothing
ol = Nothing
End Sub
End Module
Also I am running on Windows 7 with the Office 2013 suite. Looking at the App.config my supported Runtime version is v4.0 and the .NetFramework version is v4.5