Solved

Using Outlook object in VB .Net

Posted on 2004-10-15
7
229 Views
Last Modified: 2010-04-23
I am attempting to use the outlook object in VB .Net to send an email.  In the code I declare my mailItem set it up but when I issue the command mailItem.send() it comes up with an error telling me that

   'send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and 'Outlook.ItemEvents_Event'

I don't understand why this doesn't work I was working with sample code from msdn.  My other problem is that if I try to run the code anyway I get null references whenever I use the MailItem object.  But if I try to instantiate a new instance of the object I get an error saying that the _new()  method is private and cannot be access.  I am really not getting this.  
0
Comment
Question by:Seiera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12318715
this should work (ofcourse you need to reference the outlook object library, Add reference/com/microsoft outlook ...)

Dim olApp As Outlook.Application
        Dim olMail As Outlook.MailItem
        olApp = New Outlook.Application

        olMail = olApp.CreateItem(Outlook.OlItemType.olMailItem)
        olMail.Recipients.Add("bla.bla@bla.com")
        olMail.Subject = "Your subject"
        olMail.HTMLBody = "Your HTML text"
        olMail.Attachments.Add("c:\ttt.txt", Outlook.OlAttachmentType.olByValue)
        olMail.Send()

0
 
LVL 1

Author Comment

by:Seiera
ID: 12321699
Unfortunately not, I have added the reference and that is almost precisely the same code I had.  I copy and pasted it to see if I missed something but I still get both those errors.
0
 
LVL 1

Author Comment

by:Seiera
ID: 12351131
I have ended up finding the solution to my problem.  The problem is actually a bug in the .Net environment.  The Outlook object has two Send classes, on related tot he _MailItem class and another to the _ItemEvents.Event class.  To solve the problem I would (using the above piece of code) have replaced olMail.send() with

CType(olMail, Outlook._MailItem).Send()

This ensures that there is no ambiguity and the code works.  I will be posting a message in community support requesting the points back.
0
 
LVL 1

Author Comment

by:Seiera
ID: 12353400
Lunchy,

I thought I had made responses, or is that just the generic message you leave.
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 12389463
The question has been PAQ'd and the 125 points have been refunded.
RomMod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question