Solved

Send outlook express email from VB by using MAPI

Posted on 2004-10-17
9
26,452 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 94
vb6 connector to SQL Server 2 37
Microsoft Access 2010 Question 2 75
VB 6 error 5 in windows 10 but not in XP 7 56
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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…

773 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