Results 1 to 2 of 2

Thread: CDO / Mapi

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    28
    HELP!
    Could you pls tell me how i can send a msg with
    several attachments? i've tried but i get an error msg
    sending the second file.

    This is my code:

    Set objMapi = CreateObject("MAPI.Session")
    If Not objMapi Is Nothing Then
    objMapi.Logon profilename:=sProfile
    End If

    Set objMsg = objMapi.Inbox.Messages.Add
    objMsg.Subject = sSubject
    objMsg.Text = sMsg

    'Sending files
    If Not IsMissing(sFiles) Then
    sFile = Split(sFiles, ";")
    For i = LBound(sFile) To UBound(sFile)
    Set objAttach = objMsg.Attachments.Add
    With objAttach
    'THIS IS WHERE I GET THE ERROR WHEN IT HAD'S THE SECOND FILE: (i=2)
    .Source = sFile(i)
    .Type = mapiFileData
    .ReadFromFile sFile(i)
    End With
    Next i
    End If


    If you have any clue why this happens pls
    reply.
    thank you!

  2. #2
    Guest
    I hope it'll be helpful. It attaches as many files as you want. In my code the files are in a listbox.

    ' attach all selected files from the list
    AttachmentFile = lstAttachment.List(count)
    If AttachmentFile > "" Then
    For count = 0 To lstAttachment.ListCount - 1
    .AttachmentIndex = nIndex
    .AttachmentPathName = AttachmentFile
    .AttachmentPosition = nIndex
    nIndex = nIndex + 1
    Next count
    Else
    .Delete (2)
    End If
    .Send


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