'Send' is an ambiguous object - how do I fix this?

T

Thane Walkup

Greetings,

I'm trying to write an app that will reply automatically to a message
received in Outlook 2002 as part of a Rules Wizard scripting call. I
originally tried VBA, but discovered quite rapidly that Microsoft's attempts
to secure Outlook against script execution has made this impossible to do
from VBA. I've attempted to move this into a VB.NET application, and I'm
experiencing some problems with the code. I will admit up front that I have
no real experience with VB.NET, and have a small smidgen of experience with
C#.

Basically all the code is looking good, except for two bits, replyMail.Send
and objMsg.Reply. Both replyMail and objMsg are defined as:
Microsoft.Office.Interop.Outlook.MailItem

The error message I get is:

"T:\Projects\VBReplyAddIn\VBReplyAddIn\Connect.vb(53): 'Reply' is ambiguous
across the inherited interfaces 'Microsoft.Office.Interop.Outlook._MailItem'
and 'Microsoft.Office.Interop.Outlook.ItemEvents_10_Event'."

and

"T:\Projects\VBReplyAddIn\VBReplyAddIn\Connect.vb(71): 'Send' is ambiguous
across the inherited interfaces 'Microsoft.Office.Interop.Outlook._MailItem'
and 'Microsoft.Office.Interop.Outlook.ItemEvents_10_Event'."

I've tried wrapping them with 'CType' to no avail - I get the same error no
matter which type I cast to.



Here's the code snippet in question:

Public Class ReplyToMail
Public Sub ReplyToMail(ByVal objMsg As
Microsoft.Office.Interop.Outlook.MailItem)
Dim replyMail As Microsoft.Office.Interop.Outlook.MailItem ' The
reply message
Dim msg As String
Dim attach As Microsoft.Office.Interop.Outlook.Attachment ' For
walking through all attachments
Dim attachlist As String ' For storing all the attachments.

replyMail = objMsg.Reply ' Set up the initial reply.
replyMail.Subject = "Message Received:" + objMsg.Subject

msg = msg + "You may contact us through the following methods:" +
vbCrLf + vbCrLf
<snipped company information - code is just 'msg = msg + "more
information">
replyMail.Body = msg + replyMail.Body ' Add the message to the body
of the document.

For Each attach In objMsg.Attachments ' Get all attached file names.
attachlist = attachlist + "<<" + attach.FileName + ">>" + vbCrLf
Next

replyMail.Body = replyMail.Body + vbCrLf + attachlist
replyMail.Send()
End Sub
End Class

Any suggestions are much appreciated.

Thanks,
Thane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top