I've just switched from the deprecated System.Web.Mail.MailAddress to System.Net.Mail.MailAddress, but it doesn't seem to be particularly flexible when passing in a parameter holding multiple addresses when using the new System.Net.Mail.MailAddress.To.Add.
string emailAdd= "[email protected]; [email protected]";
System.Net.Mail.MailAddress.To.Add(emailAdd);
In the above example, [email protected] is emailed successfully, but [email protected] is not. I really need a way to do this since my addresses are defined in another class and passed to an email() method via a parameter. I'm simply not passing five parameters for 5 separate emails. Or indeed one and splicing on my end, .Web version is proving to be way more versatile.
This question is not a duplicate of the suggested one. The answer to the "duplicate" is add them individually, I want to add multiple addresses simultaneously. Since there is a way to do this, this question is more relevant than the one I'm accused of duplicating.
According to MSDN, the .Add() method accepts a string of comma-delimited addresses, rather than semicolon-delimited.
Therefore either changing the parameter that you are passing in to a comma-delimited string, if possible, or adding functionality to your email method to replace the semicolons with commas should resolve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With