Arrow روش ارسال ایمیل به چندین گیرنده
کد:
using System.Net.Mail;
کد:
class SendEmail
{
public static void SendMessage(string subject, string messageBody, string fromAddress, string toAddress, string ccAddress)
{
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
message.From = new MailAddress(fromAddress);
// Allow multiple "To" addresses to be separated by a semi-colon
if (toAddress.Trim().Length > 0)
{
foreach (string addr in toAddress.Split(';'))
{
message.To.Add(new MailAddress(addr));
}
}
// Allow multiple "Cc" addresses to be separated by a semi-colon
if (ccAddress.Trim().Length > 0)
{
foreach (string addr in ccAddress.Split(';'))
{
message.CC.Add(new MailAddress(addr));
}
}
message.Subject = subject;
message.Body = messageBody;
client.Host = "YourMailServer";
client.Send(message);
}
}