none
multiple attachment email RRS feed

  • Question

  • Dim f    As Object
    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True

    If f.Show Then
     
        Dim i As Integer
        For i = 1 To f.SelectedItems.Count
            bestand = bestand & f.SelectedItems(i) & " "
          Next i
        
    End If

    for 1 file , sending of mail works , for multiple files i get an error on sending emails

    why ?

    Thursday, March 17, 2016 9:28 AM

Answers

  • Hi. You'll need to add each selected file to the Attachment collection. For example:

    For i = 1 To f.SelectedItems.Count

       objMail.Attachments.Add f.SelectedItems(i)

    Next

    Hope that helps...  

    • Marked as answer by tekoko10 Saturday, March 19, 2016 7:13 AM
    Thursday, March 17, 2016 1:16 PM
  • Dim f    As Object
    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True

    If f.Show Then
     
        Dim i As Integer
        For i = 1 To f.SelectedItems.Count
            bestand = bestand & f.SelectedItems(i) & " "
          Next i
        
    End If

    for 1 file , sending of mail works , for multiple files i get an error on sending emails

    why ?

    How are you sending the mail?  What does the code for creating the message the mail and attaching the files look like?  Assuming that it can accept a string containing multiple filenames, I'd expect the filenames in that sting to be delimited by semicolons, or maybe commas, rather than spaces.  For that matter, a file path might reasonably contain spaces, anyway, so it's not safe in principle to delimit them with spaces unless you surround them with quotes.  But it's hard to do anything but speculate without seeing the code for creating the message and attaching the files.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    • Marked as answer by tekoko10 Saturday, March 19, 2016 7:12 AM
    Thursday, March 17, 2016 4:23 PM

All replies

  • Hi. You'll need to add each selected file to the Attachment collection. For example:

    For i = 1 To f.SelectedItems.Count

       objMail.Attachments.Add f.SelectedItems(i)

    Next

    Hope that helps...  

    • Marked as answer by tekoko10 Saturday, March 19, 2016 7:13 AM
    Thursday, March 17, 2016 1:16 PM
  • Dim f    As Object
    Set f = Application.FileDialog(3)
    f.AllowMultiSelect = True

    If f.Show Then
     
        Dim i As Integer
        For i = 1 To f.SelectedItems.Count
            bestand = bestand & f.SelectedItems(i) & " "
          Next i
        
    End If

    for 1 file , sending of mail works , for multiple files i get an error on sending emails

    why ?

    How are you sending the mail?  What does the code for creating the message the mail and attaching the files look like?  Assuming that it can accept a string containing multiple filenames, I'd expect the filenames in that sting to be delimited by semicolons, or maybe commas, rather than spaces.  For that matter, a file path might reasonably contain spaces, anyway, so it's not safe in principle to delimit them with spaces unless you surround them with quotes.  But it's hard to do anything but speculate without seeing the code for creating the message and attaching the files.


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    • Marked as answer by tekoko10 Saturday, March 19, 2016 7:12 AM
    Thursday, March 17, 2016 4:23 PM