Solved

Using Outlook object in VB .Net

Posted on 2004-10-15
7
233 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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