I'm going to use a code provided by godaddy.com in my contact form file. The code is not working properly. The file extension at the moment is .asp. Is this correct or should it be something else? // language -- C# // import namespace using System.Web.Mail; private void SendEmail() { const string SERVER = "relay-hosting.secureserver.net"; MailMessage oMail = new System.Web.Mail.MailMessage(); oMail.From = "emailaddress@domainname"; oMail.To = "emailaddress@domainname"; oMail.Subject = "Test email subject"; oMail.BodyFormat = MailFormat.Html; // enumeration oMail.Priority = MailPriority.High; // enumeration oMail.Body = "Sent at: " + DateTime.Now; SmtpMail.SmtpServer = SERVER; SmtpMail.Send(oMail); oMail = null; // free up resources }
Try... (the email and password are NOT required) 1 using System; 2 using System.Text; 3 using System.Net.Mail; 4 using System.Net.Mime; 5 using System.Configuration; 6 using System.Net; 7 using System.Collections.Generic; 8 9 public sealed class Email 10 { 11 public static void SendEmail(string from, List<string> to, string subject, string body) 12 { 13 MailMessage message = new MailMessage(); 14 SmtpClient smtp = new SmtpClient(); 15 16 //Get the message ready to send 17 message.From = new MailAddress(from, "Test mail"); 18 foreach (var item in to) 19 { 20 message.To.Add(new MailAddress(item)); 21 } 22 23 message.IsBodyHtml = false; 24 message.Subject = subject; 25 message.Body = body; 26 27 smtp.Host = "relay-hosting.secureserver.net"; 28 smtp.Port = 25; 29 smtp.Send(message); 30 31 } 32 }