Question:
How to send an email programmatically using GoDaddy's email account?
|
Answer:
.... // function public string SendEmail(string sFromAddress, string sToAddress, string sEmailSubject, string sEmailBody) { string sResult=""; string sEmailServer = null; string sCCEmailAddress = null; bool bSentCarbonCopy = false; try { System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); sCCEmailAddress = "yourccemail@yourdomain.com"; sEmailServer = "relay-hosting.secureserver.net"; mailMsg.From = new MailAddress(sFromAddress); mailMsg.To.Add(sToAddress); mailMsg.CC.Add(sCCEmailAddress); mailMsg.Priority = MailPriority.High; mailMsg.IsBodyHtml = true; mailMsg.Subject = sEmailSubject; mailMsg.Body = sEmailBody; System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient(sEmailServer); smtpclient.UseDefaultCredentials = true; smtpclient.Send(mailMsg); return sResult; } catch (Exception Ex) //Failed to send an email { if (Ex.Message != "") { // Your Error Loggin function } } finally { } ....
|
Need help with XHTML, ASP.NET, C# or SQL-Server? -
Contact Webmaster