Forum Discussion

Lance_101's avatar
Occasional Contributor
5 years ago

SendMail Not Working When Sending Multiple Attachments

Hello, we're having trouble using the builtin function SendMail when sending more than one attachment. It works fine if we simply call the function and pass in our arguments. But when we call the function from our wrapper function we get an error stating "The files you want to attach to the message do not exist". Our wrapper function takes the attachments as an array and iterates through the array to form a comma-separated list which is passed to SendMail along with the other six arguments. When a breakpoint is set at the point where we're calling SendMail the attachments argument correctly evaluates to the comma-separated quoted strings we're expecting (e.g., "F:\Documents\attachment_1.txt", "F:\Documents\attachment_2.txt") so we don't understand why we're getting the error.

  • Hi Lance,


    The CDO object is indeed no longer actively maintained by Microsoft, but you can still use it for sending emails (the schema still works even though its URL cannot be opened in a browser). Besides, using CDO allows you to specify the SMTP server port and use SSL for SMTP connections.


    As for the original issue with multiple attachments, it looks like the issue was with the parameter type. The SendEmail method expects each string to be passed individually, but instead, an entire array of strings was passed in a single parameter. At the same time, SendEmail always uses port 25 and doesn't allow using SSL, so it looks like using CDO will be a more appropriate solution.


7 Replies

  • tristaanogre's avatar
    Esteemed Contributor

    JavaScript uses the backslash as an "escape" character.  So, it could be that it's seeing the filenames incorrectly due to the backslash characters not being properly parsed.

    • Lance_101's avatar
      Occasional Contributor

      Thanks for the suggestion. I used the vbscript Replace function to replace \ with \\ but got the same result. Looking at the SmartBear documentation I ran across a section on using CDO that looks promising. I think I'll give that a try.

      • sonya_m's avatar
        SmartBear Alumni (Retired)

        Thank you tristaanogre!


        Hi Lance_101 , did you find a solution for this? Please let us know if you still need help from the Community.