title: Send mail with attachment
body: <p><strong>Edit</strong>: <strong>I'm able to send mail without attachment</strong> </p>
  
  <p>Getting this error while trying to send mail:</p>
  
  <pre><code>System.Net.Mail.SmtpException: The operation has timed out.
  </code></pre>
  
  <p>Following is my code:</p>
  
  <pre><code>public static void SendMailMessage(string to, string subject, string body, List&lt;string&gt; attachment)
  {
      MailMessage mMailMessage = new MailMessage();
      // string body; --&gt; Compile time error, body is already defined as an argument
  
      mMailMessage.From = new MailAddress("abc@gmail.com");
  
      mMailMessage.To.Add(new MailAddress(to));
  
      mMailMessage.Subject = subject;
  
      mMailMessage.Body = body;
  
      foreach (string s in attachment)
      {
          var att = new Attachment(s);
  
          mMailMessage.Attachments.Add(att);
  
      }
  
  
      // Set the format of the mail message body as HTML
      mMailMessage.IsBodyHtml = true;
      // Set the priority of the mail message to normal
      mMailMessage.Priority = MailPriority.High;
  
      using (SmtpClient mSmtpClient = new SmtpClient())
      {
          mSmtpClient.Send(mMailMessage);
      }
  }
  </code></pre>
  
  <p>Web Config</p>
  
  <pre><code> &lt;system.net&gt;
  &lt;mailSettings&gt;
    &lt;smtp from="mailid"&gt;
      &lt;network host="smtp.gmail.com" port="587" enableSsl="true" userName="username" password="pass" /&gt;
    &lt;/smtp&gt;
  &lt;/mailSettings&gt;
  </code></pre>
  
  <p></p>
  
  <p>Note : Attachments not exceeding its limit(below than 25 mb)</p>
  
  <p>What can I do to solve this problem, or what am I missing?</p>