I'm trying to send an email automatically using the Outlook 10.0 object library reference in VB.net
I'm using the following code:
Public Class OutlookMail
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oOutboxFolder As Outlook.MAPIFolder
Function SendOutlookItem()
oApp = New Outlook.Application()
oNameSpace = oApp.GetNamespace("MAPI"
oNameSpace.Logon("", "", True, True)
oOutboxFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
Dim oMailItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMailItem.To = "someone@somewhere.co.uk"
oMailItem.Subject = "test"
oMailItem.Body = "test"
oMailItem.SaveSentMessageFolder = oOutboxFolder
oMailItem.Send()
End Function
End Class
The problem is that I'm getting a build error -
"'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and 'Outlook.ItemEvents_10_Event'."
Does anyone know how to solve this?
Cheers
Simon
I'm using the following code:
Public Class OutlookMail
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oOutboxFolder As Outlook.MAPIFolder
Function SendOutlookItem()
oApp = New Outlook.Application()
oNameSpace = oApp.GetNamespace("MAPI"
oNameSpace.Logon("", "", True, True)
oOutboxFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
Dim oMailItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMailItem.To = "someone@somewhere.co.uk"
oMailItem.Subject = "test"
oMailItem.Body = "test"
oMailItem.SaveSentMessageFolder = oOutboxFolder
oMailItem.Send()
End Function
End Class
The problem is that I'm getting a build error -
"'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and 'Outlook.ItemEvents_10_Event'."
Does anyone know how to solve this?
Cheers
Simon