?
Solved

Using Outlook object in VB .Net

Posted on 2004-10-15
7
Medium Priority
?
244 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

777 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