RSS Feed for This PostCurrent Article

Viewing Outlook Msg File OLE Type Attachment

This is a bit tricky to view OLE type of attachment in Outlook .msg file. You need to use MsWord library in order to extract the attachment.

Here is the code snippet that does the trick.

   1: for(int loop = 1 ; loop < (mItem.Attachments.Count+1) ;  loop++){             

   2:       attachment = mItem.Attachments[loop];

   3:       if(attachment.Type == Outlook.OlAttachmentType.olOLE){

   4:           Object missing = Type.Missing;

   5:           mItem.SaveAs("C:\\temp\tmp.rtf",Outlook.OlSaveAsType.olRTF);

   6:           wordApp = new MsWord.Application();

   7:           doc = (MsWord.Document)wordApp.Documents.Open(ref filepath,ref missing,ref openRead,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref visible,ref missing,ref missing,ref missing,ref missing);

   8:           doc.InlineShapes[loop].Select();

   9:           doc.ActiveWindow.Selection.CopyAsPicture();

  10:           bm =(Bitmap)Clipboard.GetDataObject().GetData(typeof(Bitmap));

  11:           bm.Save("C:\\temp\bitmap.bmp");

  12:       }

  13: }


Trackback URL


Sorry, comments for this entry are closed at this time.