Sending Mail in Web Application

Discussion in 'Email' started by trendshandl, Oct 27, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. 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", "[email protected]");


    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");


    */


    // Send mail


    mailClient.Credentials = new System.Net.NetworkCredential( "[email protected]" , "password" ) ;





    mailClient.Send(mailMessage);


    }
     
  2. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

    What happenned with you set the smtp to "localhost"? did you receive an error? What is the error message?


    Eric
    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
     
  3. Hi Eric,


    thanks for the help. for some reason everything is fine now. I'm able to send emails. Thanks
     
  4. 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
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page