title: How to send the mail from c#
body: <p>I have code,</p>
  
  <pre><code> System.Web.Mail.MailMessage oMailMessage = new MailMessage();
              oMailMessage.From = strFromEmaild;
              oMailMessage.To = strToEmailId;
              oMailMessage.Subject = strSubject;
              oMailMessage.Body = strBody;
              SmtpMail.SmtpServer = "localhost";
              SmtpMail.Send(oMailMessage);
  </code></pre>
  
  <p>(all variables have values)</p>
  
  <p>I have installed SMTP virtual services. why it is unable to send emails. why it is not working ??</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>public bool SendMail(string strToEmailId, string strFromEmaild, string strSubject, string strBody)
  {
      try
      {
          System.Web.Mail.MailMessage oMailMessage = new MailMessage();
          oMailMessage.From = strFromEmaild;
          oMailMessage.To = strToEmailId;
          oMailMessage.Subject = strSubject;
          oMailMessage.Body = strBody;
          SmtpMail.SmtpServer = "SERVERNAME";
          SmtpMail.Send(oMailMessage);
  
          return true;
       }
       catch (Exception ex)
       {
           return false;
       }
   }
  </code></pre>
  
  <p>I have this code. It is executing fine and is returning true, but I'm not getting any email in the inbox.</p>
  
  <h1>What else could be wrong?</h1>
  
  <h2>Getting some mails in BadMail Dir at C:\Inetpub\mailroot\Badmail also in Queue Directory getting some mails here ... what does that means..??</h2>
  
  <p>I found that mail only can sent to gmail accounts... why it is?</p>