Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB.NET and Outlook problem

1 view
Skip to first unread message

Thorben G. Jensen

unread,
Jan 2, 2002, 3:10:29 PM1/2/02
to
hi all,

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


Jay B. Harlow [MVP - Outlook]

unread,
Jan 2, 2002, 7:56:16 PM1/2/02
to
Thorben,
This is on my list to look at, I just have not gotten that far.

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...

Mike Timms

unread,
Jan 2, 2002, 9:05:24 PM1/2/02
to
Hi Thorben,

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...

Thorben G. Jensen

unread,
Jan 3, 2002, 3:38:41 PM1/3/02
to
Hi Mike,

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...

0 new messages