title: C# Exchange -> Outlook Item Attachment
body: <p>Im trying to get (from my Exchange Server Outlook) my Outlook contact´s.
  im Using using C# and email.Attachments.AddItemAttachment(variable);
  I have already a connection to Outlook and can send with my script. I load all Outlookfolders.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Microsoft.Exchange.WebServices.Data;
  using Microsoft.Office.Interop.Outlook;
  //using Microsoft.Office.Interop.Outlook.MAPIFolder;
  //Imports outlook = Microsoft.Office.Interop.Outlook
  
  namespace HelloWorld
  {
      class Program
      {
          static void Main(string[] args)
          {
              ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
       RedirectionUrlValidationCallback);
              service.Url = new Uri("*******");
  
            service.Credentials = new WebCredentials("******","******");  service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;
            EmailMessage email = new EmailMessage(service);
  
  
            /////////////////////////////////////////////////////////////////////
              var outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
              NameSpace mapiNamespace = outlookApplication.GetNamespace("MAPI");
              MAPIFolder contacts = mapiNamespace.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
              for (int i = 1; i &lt; contacts.Items.Count + 1; i++)
              {
                  var contact = (ContactItem)contacts.Items[i];
                  itemAttachment.Name="contact.FullName";
                  Console.WriteLine(contact.Email1Address);
                  Console.WriteLine();
  
  
              }
                var testcontact = "adasd";
              /////////////////////////////////////////////////////////////////////
  
              email.ToRecipients.Add("********");
              email.Sender = new   Microsoft.Exchange.WebServices.Data.EmailAddress("*****");
  
              email.Subject = "Test subj";
              email.Body = new MessageBody("Test txt");
              email.Attachments.AddItemAttachment(testcontact);
  
              email.SendAndSaveCopy();
  
          }
          private static bool RedirectionUrlValidationCallback(string redirectionUrl)
          {
              // The default for the validation callback is to reject the URL.
              bool result = false;
  
              Uri redirectionUri = new Uri(redirectionUrl);
  
              // Validate the contents of the redirection URL. In this simple validation
              // callback, the redirection URL is considered valid if it is using HTTPS
              // to encrypt the authentication credentials. 
              if (redirectionUri.Scheme == "https")
              {
                  result = true;
              }
              return result;
          }
  
      }
  }
  </code></pre>
  
  <p>Does anybody know what the right Syntax is for </p>
  
  <blockquote>
    <p>email.Attachments.AddItemAttachment(testcontact);</p>
  </blockquote>
  
  <p>?</p>