title: How I can send a mail with PDF File
body: <p>I want to send a pdf file with a mail in C#. I know how I can send a mail but I don't know how I can send a mail with pdf file :(</p>
  
  <p>For example I have a pdf file in the folder C:\test.pdf </p>
  
  <p>Here is my code:</p>
  
  <pre><code>private void SendEmail(string pdfpath,string firstname, string lastname, string title, string company, string mailfrom,string mailto) 
  {
      try
      {
          MailMessage m = new MailMessage();
          System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient();
  
          m.From = new System.Net.Mail.MailAddress(mailfrom);
          m.To.Add(mailto);
  
          m.Subject = "Company Gastzugang (" + lastname + ", " + firstname + ")";
  
  
          // what I must do for sending a pdf with this email 
  
          m.Body = "Gastzugangdaten sind im Anhang enthalten";
  
          sc.Host = SMTPSERVER; // here is the smt path
  
          sc.Send(m);
      }
      catch (Exception ex)
      {
          error.Visible = true;
          lblErrorMessage.Text = "Folgender Fehler ist aufgetreten: " + ex.Message;
      }
  }
  </code></pre>