posts - 293 , comments - 426 , trackbacks - 0

My Links

News

View Steve Michelotti's profile on LinkedIn

Twitter












Tag Cloud

Archives

Post Categories

My Online Presence

Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

 

So, a morning of bashing my head an a new found appreciation for .Net…

Today I had to do some legacy app programming in vb6…

The issue we were trying to resolve was that we had an application sending emails via the MAPIMessages library. Everything worked fine in Windows XP, but if the user ran the same program in Windows 7 you would get a Runtime error ‘32002’.

After a fair amount of searching on the internet I got several conflicting reasons as to why this was “crashing”. To save those other poor soles that may come across this problem I have pasted a working vb6 solution that works in Windows 7 below…

Public Function TestEmail(ByRef MAPIMessages As MAPIMessages, ByRef MAPISession As MAPISession)
        Let MAPISession.DownLoadMail = False
        '---------------------------------------------------
        'Sign on Session
        '---------------------------------------------------
        If (MAPISession.SessionID = 0) Then
            Call MAPISession.SignOn
        End If

        With MAPIMessages
            .SessionID = MAPISession.SessionID
            .Compose
            .AddressResolveUI = False

            .MsgSubject = "This is a subject."
            .MsgNoteText = "This is a body."

            .RecipIndex = 0
            .RecipType = 1
            .RecipAddress = "smtp: youremail@gmail.com"
            .RecipDisplayName = "smtp: youremail@gmail.com"
        

            .Send False
        End With
End Function

Now there are a few gotchas that you have to be careful about…

You need to set the RecipDisplayName correctly, if you do not, even if the RecipAddress is correct it will return an error.

You also need to turn the AddressResolveUI to false…

Provided you have those two things done… it should work fine…

Good luck!

Print | posted on Tuesday, May 31, 2011 12:48 PM | Filed Under [ VB6 ]

Feedback

Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Thank You very much on this... I have been looking for this solution for ages.
I had this working fine for Thunderbird.. but Outlook is another problem.

Thank You!!!
10/11/2011 7:40 AM | Mike Neary
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Great to hear this was useful for someone.
10/11/2011 9:01 AM | Mark Pearl
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Thanks for posting, ran into the same error and I added 3 things:
.RecipIndex = 0
.RecipType = 1
.RecipDisplayName = "smtp: youremail@gmail.com"
12/15/2011 11:31 PM | Pete
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Hi there,
I have been testing similar code fragments for a few days now. I'm not getting an error but Calling MAPISession1.SignOn isn't setting SessionID (it is always 0) and so on .Compose I get error 32053 "MAPI Failure: Valid session ID does not exist". I was hoping someone could point me toward a solution.

I have been using CDO and just using my own light email from but now more customers want application output sent to their desktop email client. I'm just trying to emulate shell sendto mail from windows explorer. I didn't think the method for doing this would be top secret.

Thank you,
Ron
3/1/2012 8:33 PM | Ron
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Hi,

I have got the same error but I have attachment. How to handle attachment with MAPI?

I'd appreciate if someone could answer me. Thanks!
4/17/2012 9:58 AM | Yoyo
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Mark, you have saved me from going completely bald! I don't know which of your caveats did it, but it works, and that's all I care about. THANK YOU!
1/7/2013 3:32 AM | Bill Hileman
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Hi Mark,
I'm using Windows 8 (64) and Outlook 2010, and it is not working.
It starts an old version of Outlook (2000), I don't know why.
And then nothing happens...
I'd appreciate if you could answer me.
Thank you!
4/25/2013 3:23 AM | Sayeg
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

Hi,

It really works!
But if I have an attachment, I get the same error, like Yoyo.
How to handle attachment?

I'd appreciate if someone could answer me.
Thanks!
4/25/2013 4:04 PM | Sayeg
Gravatar

# re: Sending emails with VB6 & MAPIMessages returns Unspecified Failure has Occurred (Runtime error ‘32002’:)

How to handle multiple attachments as i am able to send 1 attachment but it gives the same error in case of multiple attachments. Did some tries from forums but in vain. Here's the code

MAPISession1.SignOn

With MAPIMessages1
.SessionID = MAPISession1.SessionID
'Start by telling the control that we are composing an e-mail
.Compose
'Use whatever is in the Textboxes as the information for our e-mail.
.RecipIndex = 0
.RecipType = 1
.RecipDisplayName = "smtp: abc@hotmail.com"
.RecipDisplayName = "smtp: abc@hotmail.com"

.MsgSubject = "MAPI subject with attachments"
.MsgNoteText = "This is atest"




.AttachmentIndex = .AttachmentCount
.AttachmentType = mapData
.AttachmentPosition = 0
.AttachmentPathName = "C:\test.csv"
.AttachmentName = "test.csv"

.AttachmentIndex = .AttachmentCount
.AttachmentType = mapData
.AttachmentPosition = 0
.AttachmentPathName = "E:\holidays_2013.xls"
.AttachmentName = "holidays_2013.csv"
.ResolveName
'Send the e-mail message to the Recipient
.Send
End With
4/29/2013 3:56 AM | abbid
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: