Saving Outlook attachment to memory

Is there a way to read an Outlook attachment directly to memory. I can only see a SaveAsFile() which wants a file path to save the attachment to. I have no need to save the attachment on disk first, just require the bytes from the attachment.



Answer this question

Saving Outlook attachment to memory

  • render77

    What type of file is it Why dont you just open the file and then read the contents you can keep the app vis false


  • AnilAli

    What you are trying to do is a known technique. The Outlook OM does not allow you to do this. The VSTO 2005 tools for Outlook (I'm the PM for these tools) do not go beyond the Outlook OM per se (it's pretty powerful on its own).

    To do this, I have traditionally used Extended MAPI. But, using Extended MAPI is not supported in .NET. You can still give it a try, but just know it is not supported. You can always drop to the metal in C++ and work with Extended MAPI and mix that into your code. I recommend reading up on these MAPI calls.

    It is helpful to remember that this forum is mainly for issues that directly pertain to the Visual Studio Tools for Office tools per se. So you will be best served by posing this question to a forum or newsgroup wholly dedicated to application-specific issues such as yours. Here is a link to resources that will help you:

    http://blogs.msdn.com/johnrdurant/archive/2005/12/07/vsto_outlook_resourcelist.aspx

    John.



  • wckdtribal

    It could be any file that contains text. .doc, .rtf, .txt, .pdf, etc. Basically, the bytes will be passed to a webservice hence there is no need to save the file locally in order to create a stream. But I dont see any way of doing this with VSTO other than saving the attachment to disk & then creating a FileStream
  • Saving Outlook attachment to memory