Solved

Send outlook express email from VB by using MAPI

Posted on 2004-10-17
9
26,440 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
  • 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 150 total points
ID: 12335737
Your code works fine here - with a reference to MS Outlook 10.0, and the mItem.Send added.
0
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This collection of functions covers all the normal rounding methods of just about any numeric value.
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now