Wednesday, November 26, 2008

sending emails Godaddy server in customised way in html format with from name

using System.Web.Mail;


const string SERVER = "relay-hosting.secureserver.net";// godaddy smtp server url

System.Web.Mail.MailMessage oMail = new System.Web.Mail.MailMessage();

oMail.From = "<>" + "Text" + " " + "Text"+ "<" + strUserEmail.Trim() +">"+ "<>";
//oMail.From =
email;

oMail.To = "receiver email";

oMail.Bcc = "bcc email";
oMail.Subject = "Contact Us (Mobile)";
oMail.BodyFormat = System.Web.Mail.MailFormat.Html; // enumeration
oMail.Priority = System.Web.Mail.MailPriority.High; // enumeration




//oMail.Body = "" + "First name: " + strFirstName + "
Last name: " + strLastName + "
Company: " + strCompanyName + "
Email: " + strUserEmail + "
Phone: " + strPhone + "
Comments: " + strBody + "";

System.Web.Mail.SmtpMail.SmtpServer = SERVER;
System.Web.Mail.SmtpMail.Send(oMail);

oMail = null; // free up resources






to have new lines use "<"br"> "tag where ever you want instead of (/n) after removing "" marks