Solved

using MAPI to email from VB

Posted on 2002-05-16
3
1,101 Views
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.Compose
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.

Thanks

Rick

I get the Message
0
Comment
Question by:Aerocom
3 Comments
 
LVL 69

Expert Comment

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

Accepted Solution

by:
Glowman earned 100 total points
Comment Utility
Aerocom,
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.Compose
MapiMess.RecipAddress = email.Text
MapiMess.ResolveName   **~~**(Add this line)
MapiMess.Send (True)
End Sub

By adding that line you should be good to go.

G
0
 
LVL 1

Author Comment

by:Aerocom
Comment Utility
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

Rick
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
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…
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…

728 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

10 Experts available now in Live!

Get 1:1 Help Now