Sending multiple emails using variables

I want to send multiple emails using ‘Send Outlook Mail Message’ activity. I understand I should separate them by ‘;’ in ‘To’ field but that might work when using email addresses in a plain text.

I’m referring to the email addresses by variables from an Excel column (as I’m creating the email addresses dynamically using users first names and last names and concatenating them with ‘@domain.com’), then I want to send emails from another column using also different variables. Any idea on how to do this?

Also, how to add an email address (without using variables) to the mailing list where variables are used?

Hi @Jasu,

“To” field on the MailMessage class accepts string format. Have a string variable to hold the addresses - you can build your email addresses using first name last name and append the domain and append “,” to separate the next email address.

string mailTo = string.Join(",", mailId);

It doesn’t matter if you are getting the email IDs from multiple sources; Build your string and then assign it to the To field.
Email Test.xaml (8.2 KB)

1 Like

You could build your addresses inside a loop that goes through each row and formulates the addresses to a string.

To be honest, I would instead use a lambda expression to create an array of addresses, then you can use String.Join()

Here is an example, assuming you are wanting to join the first and last names…

String.Join(";", table.AsEnumerable.Select(Function(r) r("First Name").ToString.Trim + "." + r("Last Name").ToString.Trim + "@domain.com" ).ToArray )

So it goes through each item in your table variable, and selects the “First Name”."Last Name"@domain.com, which creates an array of all the emails, then String.Join() to concatenate them wtih a “;” inbetween.

Assign that code to a String variable or use directly in the “TO” field of your Send Mail activity

Regards.

1 Like

@Jasu
if u have done the sequence can u share the work flow