Home System.Net.Mail.MailAddress send to multiple emails with one parameter
Reply: 2

System.Net.Mail.MailAddress send to multiple emails with one parameter

xeon48 Published in 2017-11-14 16:29:38Z

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= "email1@emailus.com; email2@emailus.com";


In the above example, email2@emailus.com is emailed successfully, but email1@emailus.com 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.

Diado Reply to 2017-11-14 16:35:15Z

According to MSDN, the .Add() method accepts a string of comma-delimited addresses, rather than colon-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 colons with commas should resolve the issue.

Ashiq Emran
Ashiq Emran Reply to 2017-11-14 17:01:01Z

In this purpose you can follow the function Parameter that it denotes actually which is show that you can use comma delimiter and function parameter is denoted as addresses which identify that you can send multiple email together using it

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315772 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO