Hey!
I need to send an e-mail message through MS Outlook, but using VB.NET in Invoke Code instead of activity. This is because i will expand it with possibility of sending invitations for meetings. The code is from code.msdn page.
My VB Code looks like this:
Dim oApp As Interop.Outlook._Application
oApp = New Interop.Outlook.Application
Dim oMsg As Interop.Outlook._MailItem
oMsg = oApp.CreateItem(Interop.Outlook.OlItemType.olMailItem)
oMsg.Subject = mailSubject
oMsg.Body = mailBody
oMsg.To = sendTo
oMsg.CC = sendCopyTo
Dim strS As String = attachmentPath
Dim strN As String = attachmentName
If attachmentPath <> "" Then
Dim sBodyLen As Integer = Int(mailBody.Length)
Dim oAttachs As Interop.Outlook.Attachments = oMsg.Attachments
Dim oAttach As Interop.Outlook.Attachment
oAttach = oAttachs.Add(strS, , sBodyLen, strN)
End If
oMsg.Send()
I created necessary variables. Also I added following namespaces:
Microsoft.Office
Microsoft.Office.Interop.Outlook
Microsoft.VisualBasic
I also encoded a reference to interop.outlook.dll using a notepad.
Unfortunatelly i receive an error message:
“Option Strict On disallows implicit conversions from ‘Object’ to ‘Microsoft.Office.Interop._MailItem’. At line 5”.
Does anyone know what am I doing wrong?