[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1118
  • Last Modified:

using MAPI to email from VB

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
Aerocom
Asked:
Aerocom
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
better use this free component to send mail: http://www.freevbcode.com/ShowCode.Asp?ID=109
0
 
GlowmanCommented:
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
 
AerocomAuthor Commented:
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

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now