473,761 Members | 10,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.Offic e.Interop.Outlo ok.MailItem

The error message I get is:

"T:\Projects\VB ReplyAddIn\VBRe plyAddIn\Connec t.vb(53): 'Reply' is ambiguous
across the inherited interfaces 'Microsoft.Offi ce.Interop.Outl ook._MailItem'
and 'Microsoft.Offi ce.Interop.Outl ook.ItemEvents_ 10_Event'."

and

"T:\Projects\VB ReplyAddIn\VBRe plyAddIn\Connec t.vb(71): 'Send' is ambiguous
across the inherited interfaces 'Microsoft.Offi ce.Interop.Outl ook._MailItem'
and 'Microsoft.Offi ce.Interop.Outl ook.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(ByV al objMsg As
Microsoft.Offic e.Interop.Outlo ok.MailItem)
Dim replyMail As Microsoft.Offic e.Interop.Outlo ok.MailItem ' The
reply message
Dim msg As String
Dim attach As Microsoft.Offic e.Interop.Outlo ok.Attachment ' For
walking through all attachments
Dim attachlist As String ' For storing all the attachments.

replyMail = objMsg.Reply ' Set up the initial reply.
replyMail.Subje ct = "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.Attachme nts ' 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
Nov 20 '05 #1
1 3864
Thane,
For a list of articles on using Outlook from .NET see:

http://www.microeye.com/resources/res_outlookvsnet.htm

To address your issue, see:

http://support.microsoft.com/?kbid=315981

Hope this helps
Jay

"Thane Walkup" <tw*****@quor um-irb.com> wrote in message
news:10******** *****@corp.supe rnews.com...
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.Offic e.Interop.Outlo ok.MailItem

The error message I get is:

"T:\Projects\VB ReplyAddIn\VBRe plyAddIn\Connec t.vb(53): 'Reply' is ambiguous across the inherited interfaces 'Microsoft.Offi ce.Interop.Outl ook._MailItem' and 'Microsoft.Offi ce.Interop.Outl ook.ItemEvents_ 10_Event'."

and

"T:\Projects\VB ReplyAddIn\VBRe plyAddIn\Connec t.vb(71): 'Send' is ambiguous
across the inherited interfaces 'Microsoft.Offi ce.Interop.Outl ook._MailItem' and 'Microsoft.Offi ce.Interop.Outl ook.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(ByV al objMsg As
Microsoft.Offic e.Interop.Outlo ok.MailItem)
Dim replyMail As Microsoft.Offic e.Interop.Outlo ok.MailItem ' The
reply message
Dim msg As String
Dim attach As Microsoft.Offic e.Interop.Outlo ok.Attachment ' For
walking through all attachments
Dim attachlist As String ' For storing all the attachments.

replyMail = objMsg.Reply ' Set up the initial reply.
replyMail.Subje ct = "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.Attachme nts ' 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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2860
by: Alan Johnson | last post by:
Consider the following code, with the interesting lines numbered in comments: class A { public : bool f(int level = 1) // line 5 { return true ; }
9
3975
by: xuatla | last post by:
compile error: test1.cpp:21: error: ISO C++ says that `T mtd::CDiffOperator::getdp(const mtd::mVector&, long int, mtd::mBCTYPE) const' and `void mtd::CDiffOperator::getdp(mtd::mVector&, const mtd::mVector&, mtd::mBCTYPE) const' are ambiguous even though the worst conversion for the former is better than the worst conversion for the latter
1
10009
by: Alex Zhitlenok | last post by:
Hi, My question is how to resolve in C# ambiguous overloaded operators? Let say, I have two unrelated classes A and B, each one implements overloaded operator + with the first parameter of type A, and the second one of type B. Let say, these are not my classes and I know nothing about the implementation. As system doesn't know what code must be used for resolving the language construction a+b (where A a; and B b;), it returns "The call...
0
2333
by: Stephen Cairns | last post by:
I have the following rpx file in a .Net solution and I am getting the following build errors which are driving me crazy and ive no idea where I have went wrong. The build errors I'm getting are as follows: - 'CheckBox' is an ambiguous reference 'CheckBox' is an ambiguous reference 'Label' is an ambiguous reference etc................. Could someone please tell me where I have gone wrong. Here is the rpx.cs file if this helps.
1
7994
by: Rob McCaughey | last post by:
Hi all! I'm a VB newbie, and trying to send an Outlook Task automatically without user intervention in a VB application. When I use the following code, if I enable the send portion (see code below) , I get an error saying "Send is ambiguous across the inherited interfaces 'Outlook._taskitem' and Outlook.itemevents.event'. Any help would be appreciated!
9
13277
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include <hash_map>//from Standard template library //and some other headers
4
2039
by: Gary Brown | last post by:
Hi, Why are fn(object parameters) and fn(params object parameters)
1
1527
by: rn5a | last post by:
Consider the following code in a VB class file: Namespace LoginUserFetchDB Public Class ZForZebra : Inherits SoapHeader Public UserName As String Public Password As String End Class Public Class GetDBRecords : Inherits WebService Private sqlCmd As SqlCommand
7
185
by: Ioannis Vranos | last post by:
In K&R2 errata page <http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html> there are some ambiguous errata, for which I propose solutions. Any comments are welcome. Ambiguous errata (mentioned first) of "The C Programming Language" 2nd Edition errata page (http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html), and
0
9333
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10107
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9945
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8768
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7324
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.