Wednesday, July 15, 2009

Multiple line in C# .NET

string str = @" hello..
This is a
multi line content";

Sending Mail in .NET 2.0

try
{

System.Net.Mail.MailMessage obj = new System.Net.Mail.MailMessage();

String message =@ "Hello
";

// for sending html contents
obj.IsBodyHtml = true;

obj.BodyEncoding = System.Text.Encoding.UTF8;
obj.Subject = txtNature.Text ;
obj.From = new System.Net.Mail.MailAddress("From Address");
obj.To.Add("To Address")
obj.Body = message;

System.Net.Mail.SmtpClient cli = new System.Net.Mail.SmtpClient();
cli.Host = "host IP or host address";//can give localhost
cli.Send(obj);

}
catch (Exception ex)
{
}