title: Create a new email with c# and attach a file Outlook 2016
body: <p>I have a list of documents and email addresses.</p>
  
  <p>I am trying to create a method I can use to iterate throw the list of emailAddresses and for each creates a new email I Outlook and attaches the corresponding document.</p>
  
  <p>The Creating the MailItem is was I get stuck.
  Found a sample on MSDN that should work from Office 2013 and forward.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Microsoft.Office.Interop.Outlook;
  
  namespace Test_Invoice
  {
      class SendviaMail
      {
          string demofile = @"C:\Desktop\test-inv\1_Test Testesen_1_010.pdf";
          public void Send()
          {
              MailItem eMail = new MailItem();
  
              eMail.Subject = "Here is Your Invoice";
              eMail.To = "test@testesen.dk";
              eMail.Body = "Dette er en test mail for TestMailApp";
  
          }
  
          public void Send(string email, string filename)
          {
  
          }
      }
  }
  </code></pre>
  
  <p>I've been trying to understand the documentation on MSDN
  and read thru a few posts on here.</p>
  
  <p>As far as I can figure out, the next step is to add the attachment (the demo file)
  If I understand it right I need something like</p>
  
  <pre><code>eMail.AttachmentAdd = demofile;
  </code></pre>
  
  <p>But that does not work.</p>
  
  <p>It might be me that does not understand the library correctly. 
  Looking at this sample from MSDN <a href="https://msdn.microsoft.com/en-us/library/bb644320.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/bb644320.aspx</a></p>
  
  <p>Results in this code:</p>
  
  <pre><code>using Microsoft.Office.Interop.Outlook;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Outlook = Microsoft.Office.Interop.Outlook;
  
  namespace Test_Invoice
  {
      class SendviaMail
      {
          string demofile = @"C:\Desktop\test-inv\1_Test Testesen_1_010.pdf";
          public void Send()
          {
              Outlook.MailItem mail = Application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
              mail.Subject = "Quarterly Sales Report FY06 Q4";
  
              //MailItem eMail = new MailItem();
  
              //eMail.Subject = "tilmelding og faktura";
              //eMail.To = "test@testesen.dk";
              //eMail.Body = "Dette er en test mail for TestMailApp";
              //eMail.AttachmentAdd
          }
  
          public void Send(string email, string filename)
          {
  
          }
      }
  }
  </code></pre>