Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPI email quirks

Status
Not open for further replies.

HughLerwill

Programmer
Nov 22, 2004
1,818
GB
Using a MAPI email routine much like the one I posted in thread222-1196390: Trying to get Visual Basic to send E-mails, please help. under Win 7
All is fine unless;
When run in a program under the Vb6 IDE or as an exe AND the IDE or the exe have been started 'run as administrator', the routine runs fine as long as Outlook is not running. If Outlook is running the routine fails to send the email after reporting error 32002 'Unspecified Failure has occured sending email' on the .Send True
Not a big headache to me as non of my exes need to be run elevated but I thought it worth a mention.
 
Solution from one of our other programs changelog after a 7 upgrade. Original Source Unknown but it wasn't long ago. If I find, I will credit.


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


yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Thanks but I am using .Send True which should present a new email message which the user completes and then sends manually.
The issue is not related to how I am handling Recipients because I am getting the error when no recipient is specified i.e. the user completes that information manually in the new email presented.
 
Sorry, i'm confused. Are you presenting the user with an Outlook message window to complete the email or is your code doing the grunt work?
Do you have the erroring code?

JaG

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
>Are you presenting the user with an Outlook message window to complete the email
Yes.

I am using the code referenced in the OP, I am not using the optional Recipient$ parameter.
It errors on .Send True when the host app is running elevated and Outlook 2010 32 bit is already running on Win 7 64 bit.
It does not error if Outlook is not already running or if the host app in not running elevated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top