|
-
Jul 26th, 2005, 04:03 AM
#1
Thread Starter
Lively Member
MAPI error handling
Hi folks can someone help with a little problem about sending emails from vb6 via outlook etc. the following code is the main extract from my code. The process works ok providing OK/YES is selected at each of the dialogs
1. 'profile not valid/enter valid name' (OK and use default)
2. a program is trying to send emails (OK these)
etc etc
and proceeding through BUT if the user selects the CANCEL button at any time i get login failure error(s) code 32003
can someone please show me how to trap this error?
VB Code:
Dim objUser As COO.clsUser
Dim strTemp As String
Dim strSubFuncName As String
Dim strEmailAttached As String
Dim strEmailGuid As String
strSubFuncName = "frmMain:MailSession"
On Error GoTo ErrHandler
MailSession = False
strEmailAttached = ComputerName
Set objUser = New COO.clsUser
objUser.GetData
MAPISession.NewSession = True
MAPISession.UserName = GetCurrentUser
MAPISession.Password = ""
MAPISession.LogonUI = True
MAPISession.SignOn
MAPIMessages.SessionID = MAPISession.SessionID
MAPIMessages.Compose
MAPIMessages.MsgIndex = -1
MAPIMessages.RecipDisplayName = objUser.RecipientName
MAPIMessages.RecipAddress = objUser.RecipientAddress
MAPIMessages.AddressResolveUI = False
MAPIMessages.ResolveName
strEmailGuid = mstrGUID
'the companyname and companycode fields are the form's static fields
strTemp = "EORDER: " & txtCompanyName.Text & " (" & txtCompanyCode.Text & ") ID: " & strEmailGuid
MAPIMessages.MsgSubject = strTemp
MAPIMessages.MsgNoteText = "Order"
MAPIMessages.AttachmentPathName = App.Path & "\" & strEmailAttached & ".xml"
MAPIMessages.send False
MailSession = True
Exit Function
ErrHandler:
ErrorHandling strSubFuncName, Err.Number, Err.Description, Err.Source
MailSession = False
End Function
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
Last edited by Hack; Jul 26th, 2005 at 07:30 AM.
ab uno disce omnes
-
Jul 26th, 2005, 04:22 AM
#2
Addicted Member
Re: MAPI error handling
You can Use the On error resume next statement at the begining of your function.
-
Jul 26th, 2005, 07:33 AM
#3
Re: MAPI error handling
VB Code:
Dim objUser As COO.clsUser
Dim strTemp As String
Dim strSubFuncName As String
Dim strEmailAttached As String
Dim strEmailGuid As String
strSubFuncName = "frmMain:MailSession"
On Error GoTo ErrHandler
MailSession = False
strEmailAttached = ComputerName
Set objUser = New COO.clsUser
objUser.GetData
MAPISession.NewSession = True
MAPISession.UserName = GetCurrentUser
MAPISession.Password = ""
MAPISession.LogonUI = True
MAPISession.SignOn
MAPIMessages.SessionID = MAPISession.SessionID
MAPIMessages.Compose
MAPIMessages.MsgIndex = -1
MAPIMessages.RecipDisplayName = objUser.RecipientName
MAPIMessages.RecipAddress = objUser.RecipientAddress
MAPIMessages.AddressResolveUI = False
MAPIMessages.ResolveName
strEmailGuid = mstrGUID
'the companyname and companycode fields are the form's static fields
strTemp = "EORDER: " & txtCompanyName.Text & " (" & txtCompanyCode.Text & ") ID: " & strEmailGuid
MAPIMessages.MsgSubject = strTemp
MAPIMessages.MsgNoteText = "Order"
MAPIMessages.AttachmentPathName = App.Path & "\" & strEmailAttached & ".xml"
MAPIMessages.send False
MailSession = True
Exit Function
ErrHandler:
Select Case Err.Number
Case 32003
Exit Sub 'more than likely, Cancel was hit...just leave
Case Else
ErrorHandling strSubFuncName, Err.Number, Err.Description, Err.Source
MailSession = False
End Select
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|