0

I am using default smpt virtula server to send mail using c# but it doesn't send any mails and also it doesn't throw any exceptions public static void SendEmail(string _FromEmail, string _ToEmail, string _Subject, string _EmailBody) {

    // setup email header . 
    SmtpMail.SmtpServer = "localhost";
    MailMessage _MailMessage = new MailMessage();

    _MailMessage.From = _FromEmail;
    _MailMessage.To = _ToEmail;
    _MailMessage.Subject = _Subject;
    _MailMessage.Body = _EmailBody;

    try
    {
        SmtpMail.Send(_MailMessage);
    }
    catch (Exception ex)
    {

        throw new ApplicationException("error has occured: " + ex.Message); 
    }

}

please help!

Ragaei
  • 1

1 Answers1

0

I'm going to guess that the SMTP service on "localhost" is not setup properly for mail relay. This means that the mail server needs to have a parent mail server it communicates to in order for messages to be sent. This is a common mistake I see.

The MSDN article on how to setup the IIS SMTP service for mail relay should help you along. However you will need to know the DNS name of your company or ISP mail server.

http://support.microsoft.com/kb/230235

Jeff
  • 1,018
  • 1
  • 10
  • 14