Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I send mail to multiple users.

I want to enter the addresses of the receivers in a textbox (txttoadress.text)separated by semicolon.
Posted

public static void SendQuickMails(string from, string to, string subject, string body)
{
    MailMessage mailMsg = new MailMessage();
    mailMsg.From = new MailAddress(from);

    string[] tos = to.Split(';');
    for (int a = 0; a < tos.Length; a++)
    {
        if (tos[a].Trim().Length != 0)
            mailMsg.To.Add(new MailAddress(tos[a]));
    }

    mailMsg.Subject = subject;
    mailMsg.Body = body;
    mailMsg.IsBodyHtml = true;
    mailMsg.Priority = MailPriority.High;

    SmtpClient mSmtpClient = new SmtpClient(); //provide your user name or password here
    mSmtpClient.Send(mailMsg);
}


you can pass multiple emails separated by semicolon (;)
 
Share this answer
 
Just add the multiple e-mail addresses to the 'To' from your mail message.
Separated by ';'

If your asking how to send a mail take a look at the 'system.net.mail' namespace.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900