Send Email to Multiple Receipents

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

internal class EMail
{
private string _cc = string.Empty;
private string _subject = string.Empty;

#region Properties
public string From
{
get;
set;
}

public string To
{
get;
set;
}

public string CC
{
get { return _cc; }
set { _cc = ((value == null) ? "" : value); }
}

public string Subject
{
get { return _subject; }
set { _subject = ((value == null) ? "" : value); }
}

public string Body
{
get;
set;
}

public string Attachments
{
get;
set;
}
#endregion

#region Public methods
public bool Send()
{
MailMessage message = new MailMessage();
message.From = new MailAddress(From);
string[] toCollection = To.Split(new char[] {','});
foreach(string str in toCollection)
{
message.To.Add(new MailAddress(str));
}


message.Subject = Subject;
message.Body = Body;
message.IsBodyHtml = true;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Send(message);

return true;
}
#endregion
}

Comments or Responses

Login to post response