AnyBody MS-MAPI Control Experts ???

The following is the MSDN provided help-page showing MAPI Control Error Messages. Buttt, they have not specified, in which property or from which method, we have to catch the runtime error(s). If you have hands-on-experience with MAPI control... plz reply me with your thinkings as solution for my problem. So, how do we catch runtime error(s) of MAPI control generally ?? I have got Error : 32002 on the "send" method call of MAPIMessage control. I have set msgIndex=-1 and "composed" a message with 32 files attachment, each of having size less than 100KB. This MAPI controls is workable for only "MS Outlook Express".
====================================================================
Error Messages, MAPI Controls

The following table lists the trappable errors for the MAPI controls.

Constant Value Description

mapSuccessSuccess 32000 Action returned successfully

mapUserAbort 32001 User canceled process- The current action was
not completed because the user canceled the
process.

mapFailure 32002 Unspecified failure has occurred

- - An unspecified error occurred during the
current action. For example, the action was
unable to delete or address mail correctly.

mapLoginFail 32003 Login has failed


Comments

  • this code is based on an example from the VB6 Black Book [microsoft omits some required properties] and it works with both Groupwise and Outlook 2003.

    [code]
    Option Compare Database
    Option Explicit

    Dim sSendTo(4) As String, iRecip As Byte
    Dim sSubj As String, sMsg As String
    Dim sAttachFile As String, sAttachName As String
    Dim i As Byte


    Private Sub cmdSend_Click()
    Dim tmp(4) As String

    On Error GoTo errh

    'LOOKUP VALUES
    DoCmd.Requery
    tmp(0) = DLookup("sendto1", "tblsendmail") & ""
    tmp(1) = DLookup("sendto2", "tblsendmail") & ""
    tmp(2) = DLookup("sendto3", "tblsendmail") & ""
    tmp(3) = DLookup("sendto4", "tblsendmail") & ""
    tmp(4) = DLookup("sendto5", "tblsendmail") & ""
    sSubj = DLookup("subject", "tblsendmail") & ""
    sMsg = DLookup("message", "tblsendmail") & ""
    ' sAttachName = DLookup("attachname", "tblsendmail") & ""
    sAttachFile = DLookup("attachoutlook", "tblsendmail") & ""
    sAttachName = Right(sAttachFile, instrrev(sAttachFile, "") - 1)

    iRecip = 0
    For i = 0 To 4
    If tmp(i) <> "" Then
    sSendTo(iRecip) = tmp(i)
    iRecip = iRecip + 1
    End If
    Next

    If iRecip > 0 Then SendMail 'USE MAPI CONTROL TO SEND EMAIL ATTACHMENT

    xit:
    Exit Sub

    errh:
    MsgBox Err.Description, vbCritical, Err.Number
    Resume xit
    End Sub


    Private Sub SendMail()
    'KB113033 How to Send a Mail Message Using Visual Basic MAPI Controls
    'MAPI constants from CONSTANT.TXT file:
    Const ATTACHTYPE_DATA = 0
    Const RECIPTYPE_TO = 1
    Const RECIPTYPE_CC = 2

    On Error GoTo errh

    'Open up a MAPI session:
    Me.MAPIsession1.downloadmail = False '4/22/03
    Me.MAPIsession1.SignOn
    'Point the MAPI messages control to the open MAPI session:
    Me.MAPImessages1.SessionID = Me.MAPIsession1.SessionID

    Me.MAPImessages1.msgindex = -1 '4/22/03
    Me.MAPImessages1.Compose

    'Set the subject of the message:
    Me.MAPImessages1.MsgSubject = sSubj
    'Set the message content:
    Me.MAPImessages1.MsgNoteText = sMsg

    'The following four lines of code add an attachment to the message,
    'and set the character position within the MsgNoteText where the
    'attachment icon will appear. A value of 0 means the attachment will
    'replace the first character in the MsgNoteText. You must have at
    'least one character in the MsgNoteText to be able to attach a file.
    Me.MAPImessages1.AttachmentPosition = 0
    'Set the type of attachment:
    Me.MAPImessages1.AttachmentType = ATTACHTYPE_DATA
    'Set the icon title of attachment:
    Me.MAPImessages1.AttachmentName = sAttachName
    'Set the path and file name of the attachment:
    Me.MAPImessages1.AttachmentPathName = sAttachFile

    'Set the recipients
    For i = 0 To iRecip - 1
    Me.MAPImessages1.RecipIndex = i ' 0
    Me.MAPImessages1.RecipType = RECIPTYPE_TO
    Me.MAPImessages1.RecipDisplayName = sSendTo(i)
    'Me.MAPImessages1.RecipAddress = sSendTo(i) 'cSendTo 4/22/03
    Next

    'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
    'the recipient address in MapiMessages1.RecipAddress
    'If the E-Mail name is not valid, a trappable error will occur.
    'Me.MAPImessages1.ResolveName 'comment out due to unknown receiptent error w/ GW6.5 1/5/04
    'Send the message:
    Me.MAPImessages1.Send True 'add true arg, 4/22/03

    xit:
    'Close MAPI mail session:
    Me.MAPIsession1.SignOff
    Exit Sub

    errh:
    MsgBox Err.Description, vbCritical, Err.Number
    Resume xit
    End Sub
    [/code]
  • I am not satisfied with this code. I need some more needfule that i have already mensioned in my message. I can send message, but tell me about catching the post-sending errors.

    : this code is based on an example from the VB6 Black Book [microsoft omits some required properties] and it works with both Groupwise and Outlook 2003.
    :
    : [code]
    : Option Compare Database
    : Option Explicit
    :
    : Dim sSendTo(4) As String, iRecip As Byte
    : Dim sSubj As String, sMsg As String
    : Dim sAttachFile As String, sAttachName As String
    : Dim i As Byte
    :
    :
    : Private Sub cmdSend_Click()
    : Dim tmp(4) As String
    :
    : On Error GoTo errh
    :
    : 'LOOKUP VALUES
    : DoCmd.Requery
    : tmp(0) = DLookup("sendto1", "tblsendmail") & ""
    : tmp(1) = DLookup("sendto2", "tblsendmail") & ""
    : tmp(2) = DLookup("sendto3", "tblsendmail") & ""
    : tmp(3) = DLookup("sendto4", "tblsendmail") & ""
    : tmp(4) = DLookup("sendto5", "tblsendmail") & ""
    : sSubj = DLookup("subject", "tblsendmail") & ""
    : sMsg = DLookup("message", "tblsendmail") & ""
    : ' sAttachName = DLookup("attachname", "tblsendmail") & ""
    : sAttachFile = DLookup("attachoutlook", "tblsendmail") & ""
    : sAttachName = Right(sAttachFile, instrrev(sAttachFile, "") - 1)
    :
    : iRecip = 0
    : For i = 0 To 4
    : If tmp(i) <> "" Then
    : sSendTo(iRecip) = tmp(i)
    : iRecip = iRecip + 1
    : End If
    : Next
    :
    : If iRecip > 0 Then SendMail 'USE MAPI CONTROL TO SEND EMAIL ATTACHMENT
    :
    : xit:
    : Exit Sub
    :
    : errh:
    : MsgBox Err.Description, vbCritical, Err.Number
    : Resume xit
    : End Sub
    :
    :
    : Private Sub SendMail()
    : 'KB113033 How to Send a Mail Message Using Visual Basic MAPI Controls
    : 'MAPI constants from CONSTANT.TXT file:
    : Const ATTACHTYPE_DATA = 0
    : Const RECIPTYPE_TO = 1
    : Const RECIPTYPE_CC = 2
    :
    : On Error GoTo errh
    :
    : 'Open up a MAPI session:
    : Me.MAPIsession1.downloadmail = False '4/22/03
    : Me.MAPIsession1.SignOn
    : 'Point the MAPI messages control to the open MAPI session:
    : Me.MAPImessages1.SessionID = Me.MAPIsession1.SessionID
    :
    : Me.MAPImessages1.msgindex = -1 '4/22/03
    : Me.MAPImessages1.Compose
    :
    : 'Set the subject of the message:
    : Me.MAPImessages1.MsgSubject = sSubj
    : 'Set the message content:
    : Me.MAPImessages1.MsgNoteText = sMsg
    :
    : 'The following four lines of code add an attachment to the message,
    : 'and set the character position within the MsgNoteText where the
    : 'attachment icon will appear. A value of 0 means the attachment will
    : 'replace the first character in the MsgNoteText. You must have at
    : 'least one character in the MsgNoteText to be able to attach a file.
    : Me.MAPImessages1.AttachmentPosition = 0
    : 'Set the type of attachment:
    : Me.MAPImessages1.AttachmentType = ATTACHTYPE_DATA
    : 'Set the icon title of attachment:
    : Me.MAPImessages1.AttachmentName = sAttachName
    : 'Set the path and file name of the attachment:
    : Me.MAPImessages1.AttachmentPathName = sAttachFile
    :
    : 'Set the recipients
    : For i = 0 To iRecip - 1
    : Me.MAPImessages1.RecipIndex = i ' 0
    : Me.MAPImessages1.RecipType = RECIPTYPE_TO
    : Me.MAPImessages1.RecipDisplayName = sSendTo(i)
    : 'Me.MAPImessages1.RecipAddress = sSendTo(i) 'cSendTo 4/22/03
    : Next
    :
    : 'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
    : 'the recipient address in MapiMessages1.RecipAddress
    : 'If the E-Mail name is not valid, a trappable error will occur.
    : 'Me.MAPImessages1.ResolveName 'comment out due to unknown receiptent error w/ GW6.5 1/5/04
    : 'Send the message:
    : Me.MAPImessages1.Send True 'add true arg, 4/22/03
    :
    : xit:
    : 'Close MAPI mail session:
    : Me.MAPIsession1.SignOff
    : Exit Sub
    :
    : errh:
    : MsgBox Err.Description, vbCritical, Err.Number
    : Resume xit
    : End Sub
    : [/code]
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories