Null Argument

Hello,

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.

Thanks,
Brad

  1. Take path exist activity .

  2. pass attachment path

  3. in output (in property) , u will get Boolean value.

  4. if Boolean is true , u use SMTP with attachment path , else Boolean is false u just use SMTP without attachment path .

        Or 
    

You can directly use
1 ) in “if” condition , check string.isnullorempty(attachment path argument)
2 if condition false , use smtp with attachment path .
3) if condition true , use SMTP , but don’t pass attachment path.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.