Solved

Send outlook express email from VB by using MAPI

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

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
This collection of functions covers all the normal rounding methods of just about any numeric value.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

739 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