Thursday, July 19, 2007

How to send mail on a GoDaddy hosted website, using ASP.NET (C#)

//Right click on class library
//Add Reference option
//.NET Components
//System.Web -> then add it, now you can type using System.Web.Mail

using System.Web.Mail;

public class EmailInfo //instantiate this on the page that you have your info to email
private string fromemailaddress = "";
private string toemailaddress = "";
private string host = "";

//These private strings are the connection information, they are private so someone couldn't
//download your DLL and do simple code to figure out the value of these

public void SendMail(string body) //I built the body in a function in the behind-code
MailMessage message = new MailMessage();
message.From = fromemailaddress;
message.To = toemailaddress;
message.Subject = ;
message.BodyFormat = MailFormat.Html;
message.Priority = MailPriority.Normal;
message.Body = body;
SmtpMail.SmtpServer = host;
message = null;

No comments:

Post a Comment