MAPI mail

C

cj

My application, brx729, creates a new MAPI email message and leaves it
on the screen for the user to send. On one pc when it creates the email
if you cancel the message my program throws the error

System.Runtime.InteropServices.COMException (0x800A7D01): User cancelled
process
at MSMAPI.MAPIMessagesClass.Send(Object vDialog)
at brx729.Form1.SndMAPIMail(String subj, String msg)
at brx729.Form1.MailMenuItem_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

On my pc it doesn't show any error. I have installed the program on the
network so we're using the same exe.

Here's my sub that creates the email.

Private Sub SndMAPIMail(ByVal subj As String, ByVal msg As String)
Dim myMAPISession As New MSMAPI.MAPISession
Dim myMAPIMessage As New MSMAPI.MAPIMessages

myMAPISession.DownLoadMail = False
myMAPISession.SignOn()
myMAPISession.NewSession = True

myMAPIMessage.SessionID = myMAPISession.SessionID

myMAPIMessage.Compose()

myMAPIMessage.MsgSubject = subj
myMAPIMessage.MsgNoteText = msg

myMAPIMessage.Send(True)
myMAPISession.SignOff()
myMAPISession.NewSession = False
End Sub


Any idea what is going on?
 
C

cj

Hummm, putting try catch around the sub fixed the problem, or maybe I
should say symptom. Here's the new sub. New question is why did it
work? I thought after the program launched the email message it broke
all ties with it. And why did it work w/o this try catch on my pc?
Hummmm. Well, if I find out before anyone posts I'll post my findings.

Private Sub SndMAPIMail(ByVal subj As String, ByVal msg As String)
Try
Dim myMAPISession As New MSMAPI.MAPISession
Dim myMAPIMessage As New MSMAPI.MAPIMessages

myMAPISession.DownLoadMail = False
myMAPISession.SignOn()
myMAPISession.NewSession = True

myMAPIMessage.SessionID = myMAPISession.SessionID

myMAPIMessage.Compose()

myMAPIMessage.MsgSubject = subj
myMAPIMessage.MsgNoteText = msg

myMAPIMessage.Send(True)
myMAPISession.SignOff()
myMAPISession.NewSession = False
Catch
End Try
End Sub
 
G

Gary Chang[MSFT]

Hi,

Thank you posting!

Based on the error message, the exception is thrown from the underlying
MAPI DLL, your VB.NET code seems all right. In this regard, I think you can
consult this issue in our MAPI specific newsgroup, you may get some
different ideas there:

microsoft.public.platformsdk.mapi

Thanks for your understanding.
Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gary Chang[MSFT]

You are welcome. :)

Good Luck!


Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top