title: Send email with attachment from a specific url in C#
body: <p>In my view, users can search for a document and once they get the result, they can click on its id and they can download the document from specific url based on id: <a href="http://test.com/a.ashx?format=pdf&amp;id=" rel="nofollow">http://test.com/a.ashx?format=pdf&amp;id=</a>{0}</p>
  
  <p>For example, if the id is 10, then url to download document will be: <a href="http://test.com/a.ashx?format=pdf&amp;id=10" rel="nofollow">http://test.com/a.ashx?format=pdf&amp;id=10</a>, and when user click on it they are able to download the document.</p>
  
  <p>This is how it looks like in my view:</p>
  
  <pre><code> foreach (var item in Model)
          {
  
                  &lt;td&gt;
                      &lt;a href=@string.Format("http://test.com/a.ashx?format=pdf&amp;id={0}",item.id)&gt;
                          @Html.DisplayFor(modelItem =&gt; item.id)
                      &lt;/a&gt;
                  &lt;/td&gt;
          }
  </code></pre>
  
  <p>And below is my controller action for SendEmail.</p>
  
  <p>I am able to send email to the user. But i am having problem with sending attachments. 
  My question is: how can i attach the document that comes with the url to the email?</p>
  
  <pre><code> public static bool SendEmail(string SentTo, string Text, string cc)
      {
  
          MailMessage msg = new MailMessage();
  
          msg.From = new MailAddress("test@test.com");
          msg.To.Add(SentTo);
          msg.CC.Add(cc);
          msg.Subject = "test";
          msg.Body = Text;
          msg.IsBodyHtml = true;
  
          System.Net.Mail.Attachment attachment;
          attachment = new System.Net.Mail.Attachment(???);
          msg.Attachments.Add(attachment);
  
          SmtpClient client = new SmtpClient("mysmtp.test.com", 25);
  
          client.UseDefaultCredentials = false;
          client.EnableSsl = false;
          client.Credentials = new NetworkCredential("test", "test");
          client.DeliveryMethod = SmtpDeliveryMethod.Network;
          //client.EnableSsl = true;
  
          try
          {
              client.Send(msg);
          }
          catch (Exception)
          {
              return false;
          }
          return true;
      }
  </code></pre>