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.