PDA

View Full Version : Sending Mail in Web Application


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);


}

Eric
10-29-2007, 01:20 AM
What happenned with you set the smtp to "localhost"? did you receive an error? What is the error message?


Eric
http://www.DiscountASP.NET (http://www.discountasp.net/) - Microsoft Gold Certified Partner
- asp.netPRO Magazine 2007 Readers' Choice Award for Best ASP.NET Hosting Service
- Visual Studio Magazine 2007 Readers' Choice Award for Best .NET Hosting Service

trendshandl
10-29-2007, 02:31 AM
Hi Eric,


thanks for the help. for some reason everything is fine now. I'm able to send emails. Thanks

trendshandl
10-29-2007, 11:24 AM
Can anyone help me with this. Tech support is providing limeted help for this issue. They asked me to use "localhost" as smtp server. but i still cannot send mail. Thanks