I get the following error when i try to compile this code:
"ERROR: 'Send' is ambiguous across the inherited interfaces
'Outlook._MailItem' and 'Outlook.ItemEvents_10_Event'."
What does this mean?
Hope somebody can help
Thorben
PS: I am using VB.Net RC1 and Office XP
Public Class OutlookMail
Public Function SendMail(ByVal toVal As String, ByVal subjectVal As String,
ByVal bodyVal As String, Optional ByVal Attachment As String = "")
Dim ol As New Outlook.Application()
Dim ns As Outlook.NameSpace
Dim fdMail As Outlook.MAPIFolder
ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
'create a new MailItem object
Dim newMail As Outlook.MailItem
'gets defaultfolder for my Outlook Outbox
fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
'newMail.SaveSentMessageFolder = fdMail
If Attachment <> "" Then
newMail.Attachments.Add(Attachment)
End If
'Send the mail
newMail.Send() '------ This is the line that generates the error -----------
End Function
End Class
Off hand, it sounds like the interop is getting confused about the Send
event & the Send method of the MailItem...
Its seems to work in Beta 2. Have you reported it at
http://beta.visualstudio.net
Hope this helps
Jay
"Thorben G. Jensen" <nospa...@dangaard.dk> wrote in message
news:Of3lOn8kBHA.2260@tkmsftngp05...
This looks like another bug in the generated COM library.
A temporary workaround is to disambiguate the method invokation by casting
to the correct base interface.
Replace:
newMail.Send() '------ This is the line that generates the
error -----------
With:
CType(newMail, Outlook._MailItem).Send()
- Mike
"Thorben G. Jensen" <nospa...@dangaard.dk> wrote in message
news:Of3lOn8kBHA.2260@tkmsftngp05...
Thanks a lot, that did the trick.
I found quite a few similar bugs in the office interop, but they all are
fixed now following your remedy.
Thorben G. Jensen
"Mike Timms" <mti...@sympatico.ca> skrev i en meddelelse
news:u$Fqfs$kBHA.2080@tkmsftngp04...