title: Office 365 send email with attachment using OutlookServicesClient
body: <p>I'm trying to send out some e-mails on behalf of users of my LOB application.  I'm using the Office 365 connected service API so that I can authenticate using OAuth.  My code will send the e-mail, but no attachments show up.  Here is an isolated example of my code:  </p>
  
  <pre><code>    static async void SendUsingOutlookClient(CommunicationRow me, OutlookServicesClient outlook)
      {
          var m = new Message();
          m.From = ToRecipient(me.From);
          m.Body = new ItemBody { Content = me.Body };
          if (me.IsBodyHtml)
              m.Body.ContentType = BodyType.HTML;
          else
              m.Body.ContentType = BodyType.Text;
          m.Subject = me.Subject;
          m.CcRecipients.Add(me.Cc);
          m.BccRecipients.Add(me.Bcc);
          m.ToRecipients.Add(me.To);
          foreach (var attach in me.Attachments)
          {
              var file = attach.File;
              var fileversion = file.GetVersion(attach.Version);
              string fullpath = LibraryServiceImpl.GetFullNameInArchive(fileversion);
              var mattach = new FileAttachment { Name = file.Name, ContentId = attach.ContentId, ContentLocation = fullpath, ContentType = GraphicUtils.DetermineMime(Path.GetExtension(fullpath)) };
              if (file.Name.MissingText())
                  mattach.Name = attach.ContentId + fileversion.FileExtension;
              m.Attachments.Add(mattach);
          }
          await outlook.Me.SendMailAsync(m, true);
      }
  </code></pre>
  
  <p>The OutlookServicesClient I am using was found here <a href="https://visualstudiogallery.msdn.microsoft.com/a15b85e6-69a7-4fdf-adda-a38066bb5155" rel="nofollow">https://visualstudiogallery.msdn.microsoft.com/a15b85e6-69a7-4fdf-adda-a38066bb5155</a></p>