Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send outlook express email from VB by using MAPI

Posted on 2004-10-17
9
Medium Priority
?
26,474 Views
Last Modified: 2008-01-09
I used following code to send email from my application, the outlook express did pop up, and the recipient email address is automatically inserted, and I type in the title of the message and the message itself, send it out without getting any error message, but the recipient never receive it, I appreciate if anybody has any idea what might be the problem?

 Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
        Dim mOutLookApp As Outlook.Application
        Dim mNameSpace As Outlook.NameSpace
        Dim mItem As Outlook.MailItem

        mOutLookApp = New Outlook.Application
        mNameSpace = mOutLookApp.GetNamespace("MAPI")
        'mNameSpace.Logon(, , False, True)

        mItem = mOutLookApp.CreateItem(0)
        mItem.To = txtEmail.Text
        mItem.Display()
    End Sub
0
Comment
Question by:cocoWang
[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
  • 6
  • 2
9 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 12335626
Does mItem.Send work?
0
 

Author Comment

by:cocoWang
ID: 12335690
When I insert mItem.send right after the line mItem.Display, I got following error message:

System.Runtime.InterOpServices.ComException(oxD0704005):Exception from HRESULT: oxD0704005.
at Outlook._MailItem.Send()

But the Outlook express still pop up, and I still can type in the message and send out message, the problem is message never reach the recipient side.
0
 
LVL 11

Accepted Solution

by:
bingie earned 450 total points
ID: 12335737
Your code works fine here - with a reference to MS Outlook 10.0, and the mItem.Send added.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:cocoWang
ID: 12335754
My MS Outlook is "Microsoft Outlook 9.0 Object Library", do you mean I have to download MS Outlook 10.0 version and try again?

I will try it anyway, and let you know the results.  Thanks for your help. Meanwhile do I have to install ansmtp, which can be downloaded  from internet?
0
 

Author Comment

by:cocoWang
ID: 12335800
I downloaded the file "officexp-kb828040-client-enu.exe" from internet, but when I try to open this file, I got error message

The expected version of the product was not found on your system

It is because I am using Outlook express, not Outlook, do we have Outlook Express version 10.0  ?
0
 

Expert Comment

by:niranjanrampure
ID: 12337428
why dont u use MAPI controls directly. i had done this .MAPI Uses u r default mailing program.it can be anything Outloox Express or outlook. but the only drawback i found with outlook was that  i could not send multiple attachment at one time .

try this :

1.select  Microsoft MApi Controls from component
2. add mapi session and mapi messaging control  to u r form
3. sign on with help of mapi session
   ----mapisession1.signon
4 assign mapisessionId to mapimessaging.session ID
-----mapimessage1.sessionId=mapisession1.sessionid
5. compose a new message
------mapimessage1.compose
6. open outlook address book with
 ------ mapimessage1.show
7. the mapi message control will pick up all the recipents addresses u sellect from the address book
8. u can add attachments-write text messages as well as write subject
9 use mapimessage1.send to send message
10 on sending message sign off



u can receive all u r messges and send all pending messages through mapi

0
 

Author Comment

by:cocoWang
ID: 12337876
Hi Bingie,

I have Outlook at office, and Outlook Express at home. This morning I tried to open that file 'officexp-kb828040-client-enu.exe' in the office, and hopefully it will load the Outlook version 10.0 on my PC, I got following message

"This update has already been applied or is included in an update that has already been applied"

Then I checked my Outlook, it is version '10.6515.6626' SP3.  So I ran my application again, and send my email, situation is the same, recipient did not receive the email, are you sure that you have tested my coding on your machine, and they worked fine?  Do I have to download other package?

0
 

Author Comment

by:cocoWang
ID: 12337901
Hi  niranjanrampure,

I would like to give it a try, maybe I will come up with some questions, and ask you later after my trial. Thanks for your help!
0
 

Author Comment

by:cocoWang
ID: 12338315
Hi Bingie,

Good news! Finally the recipients received the email, but it took about 20 to 35 minutes for recipient to get the message, is there any other command to speed up the process?
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

722 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