Results 1 to 5 of 5

Thread: MAPI Email experts Only!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    Talking

    Hello,

    I'm trying to attach a file to an email. Does anyone know hoe to do this? Currently I'm getting run-time error 32002. The program stops at this line: (MAPIMessages1.Send True) Here's the coding (Any Ideas?):
    '
    MAPISession1.SignOn ' log into MAPI server
    MAPIMessages1.SessionID = MAPISession1.SessionID
    '
    MAPIMessages1.Compose ' clear buffer
    MAPIMessages1.RecipDisplayName = "Carr_Sherrell@Dell.com"
    MAPIMessages1.MsgSubject = "User's CONFIG.SYS File"
    MAPIMessages1.MsgNoteText = "Here is the CONFIG.SYS File" + Chr(13) + " "
    '
    MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText)
    MAPIMessages1.AttachmentType = mapData
    MAPIMessages1.AttachmentName = "System Configuration File"
    MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS"
    '
    MAPIMessages1.Send True 'send it
    '
    MAPISession1.SignOff ' exit MAPI server
    '

    Thanks
    '


    212 will lead you to the truth

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Looks like you are missing this line.

    MAPIMessages1.RecipAddress = "Carr_Sherrell@Dell.com"

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    35
    Modified, from the VB6 Samples:

    Public Function Send(ByVal RecipAddress As String, _
    ByVal MsgSubject As String, _
    ByVal MsgNoteText As String, _
    ByVal AttachmentPathName As String) As String

    'Startet die EMail.App zum versenden einer Mail
    'Quelle: VB6-Beispiel 'PRJMAPI.VBP'

    Dim curStep As Integer 'zum Lokalisieren man evt. Fehler

    On Error GoTo mapiErr
    curStep = 1
    If mapSess.NewSession Then
    Else
    With mapSess
    .DownLoadMail = False 'Set DownLoadMail to False to prevent immediate download.
    curStep = 2
    .LogonUI = True 'Use the underlying email system's logon UI.
    curStep = 3
    .SignOn 'Signon method.
    curStep = 4
    .NewSession = True
    curStep = 5
    mapMess.SessionID = .SessionID 'You must set this before continuing.
    End With
    End If
    With mapMess
    'Use the Compose method and then invoke the
    'Send method. When the optional argument
    'is set to True, the underlying mail system's
    'form is used. Otherwise, you must create your
    'own.
    curStep = 6
    .Compose
    If Len(RecipAddress) Then _
    .RecipAddress = RecipAddress
    .MsgSubject = MsgSubject
    .MsgNoteText = MsgNoteText
    .AttachmentPathName = AttachmentPathName
    curStep = 7
    .Send True
    End With
    curStep = 8
    With mapSess
    .SignOff 'Close the session.
    .NewSession = False 'Flag for new session.
    End With

    Unload Me
    Exit Function

    mapiErr:
    Send = ErrorStr(Err, Error$) & " (" & curStep & ")"
    Unload Me
    Exit Function

    End Function



    rfo

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    The AttachmentPosition property is zero based, so you should use:
    MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177
    Sorry guys, I found the answer. When doing an attachment you must specify the index just like an array. Here's the working code:

    With MAPIMessages1
    .MsgIndex = -1
    .Compose
    .RecipDisplayName = txtAddressee1.Text
    .MsgSubject = txtSubject.Text
    .MsgNoteText = rtbMessage.Text
    .AttachmentIndex = 0
    .AttachmentPathName = AttachmentPath
    .AttachmentName = AttachmentName
    .AttachmentPosition = 0
    .AttachmentType = 2
    .ResolveName
    .SessionID = MAPISession1.SessionID
    .Send 'True
    End With

    Thanks for the help. I should have posted that I had found the problem sooner. Thanks again.
    212 will lead you to the truth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width