Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;

    catch (Exception ex)

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


please help!

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.