Working with attachments

The attachments of a message can be split into to categories:
  • Usual file attachments, accessed through Message.Attachments
  • Inline attachments, such as built-in images, accessed through Message.EmbeddedResources

Downloading attachments

By default, the library will not download the attachments automatically (unless you configure the client to do this). To download an attachment manually, do the following:

/* .. Init client, authenticate .. */        
/* .. folder = any folder .. */  
/* .. message = any message .. */  

var folderPath = @"C:\attachments";

foreach (var file in message.Attachments)
{
      file.Download(); // Downloading the attachment
}

Getting attachment data and saving files to disk

/* .. Init client, authenticate .. */        
/* .. folder = any folder .. */  
/* .. message = any message .. */  

var folderPath = @"C:\attachments";

foreach (var file in message.Attachments)
{
      file.Download(); // Downloading the attachment

      /*
            After downloading the attachment you can access its data
            through the FileData property.
      */     

      /*
            To save the file directly to disk, use the Save method.
      */     

      file.Save(folderPath /*, optional file name*/);
}


Next

Last edited May 1, 2014 at 1:38 PM by pavel_azanov, version 3