I’m sending an email with potentially multiple zipped folders attached. I have used ‘in’ arguments for the attachments to send mail via SMTP. I’m attaching file paths for the attachments needed. The process works perfectly when all the arguments have valid file paths.
My issue is when there is not an attachment required, the in argument is null.
The error I receive is: ‘System.ArgumentException: The parameter ‘fileName’ cannot be an empty string. Parameter name: fileName’
The error I receive is what I should expect. I want the fileName to be empty, because based on business logic, there is nothing that should be attached.
My question is: Can I somehow add/delete arguments based on if they are needed? Or is there a better method to attach any number of folders as attachments to an SMTP email.