trendshandl
10-27-2007, 09:11 AM
I cannot send emails using my web app. below is the code i'm using
public static void SendMail(string from, string to, string subject, string body)
{
// Configure mail client (may need additional
// code for authenticated SMTP servers)
SmtpClient mailClient = new SmtpClient("smtp.mywebsite.com",587);
// Create the mail message
MailMessage mailMessage = new MailMessage(from, to, subject, body);
/*
// For SMTP servers that require authentication
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "postmaster@trendshandling.com");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
*/
// Send mail
mailClient.Credentials = new System.Net.NetworkCredential( "postmaster@mywebsite.com" , "password" ) ;
mailClient.Send(mailMessage);
}
public static void SendMail(string from, string to, string subject, string body)
{
// Configure mail client (may need additional
// code for authenticated SMTP servers)
SmtpClient mailClient = new SmtpClient("smtp.mywebsite.com",587);
// Create the mail message
MailMessage mailMessage = new MailMessage(from, to, subject, body);
/*
// For SMTP servers that require authentication
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "postmaster@trendshandling.com");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
*/
// Send mail
mailClient.Credentials = new System.Net.NetworkCredential( "postmaster@mywebsite.com" , "password" ) ;
mailClient.Send(mailMessage);
}