using MAPI to email from VB

Posted on 2002-05-16
Medium Priority
Last Modified: 2010-05-18
I have a form showing contact data for clients and an email button to open the default MAPI client ready to fill in a message to the address shown on the form. The code behind the button is

Private Sub cmdemail_Click()
 cmdemail.Enabled = False
 MAPISess.Action = 1
    MapiMess.SessionID = MAPISess.SessionID
MapiMess.RecipAddress = email.Text
MapiMess.Send (True)
End Sub

On a machine using Outlook Express as the email client everything works well clicking on the button opens Outlook Express  with the recipients address filled in ans the email can be sent.

When the program is run on a PC running Outlook 2000
The code halts at 'MapiMess.Send (True)'

and I get the error message 'runtime error 32002 Unspecified failure has occured'

Anybody seen this before and know of a work around.

I need the function to work in both Outlook and outlook express.



I get the Message
Question by:Aerocom
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
LVL 70

Expert Comment

by:Éric Moreau
ID: 7013798
better use this free component to send mail: http://www.freevbcode.com/ShowCode.Asp?ID=109

Accepted Solution

Glowman earned 400 total points
ID: 7013871
I had the exact same problem using the MAPI controls and I found out that you need to use the "ResolveName" method before each address is added.  So your code would be changed to this :

Private Sub cmdemail_Click()
cmdemail.Enabled = False
MAPISess.Action = 1
   MapiMess.SessionID = MAPISess.SessionID
MapiMess.RecipAddress = email.Text
MapiMess.ResolveName   **~~**(Add this line)
MapiMess.Send (True)
End Sub

By adding that line you should be good to go.


Author Comment

ID: 7013926
Thanks Glowman it did the trick!!

It now works with outlook as well as O express.

I've been trying for days to find out what the error refered to but no luck on MSDN. Prooves that Experts Exchange is the place to go for those solutions that MS cannot or will not provide!!

Now I have to find out if it will work with Lotus Notes which a couple of my clients use.

Thanks again


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 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