81917

Outlook MailItem as Stream

Question:

Is it possible to return a MailItem directly as a <strong>Stream</strong>? (<em>MailItem from Microsoft.Office.Interop.Outlook</em>)

Now I have found a temporary solution to first save a MailItem to a directory, opening it and returning the stream to the file and afterwards deleting the file again.

This temporary solution is slow when processing lots of emails and I would like to replace it with e.g. returning a MailItem as MemoryStream directly.

How can this be done?

(<strong>Edit due to comments:</strong> being slow is one part, but another codepart (that cannot be modified) only accepts a Stream, that's way I'm looking for a solution to open a MailItem as a Stream)

Answer1:

I had a thought to your slow problem. I ran across something that may make a massive difference when writing mine.

When I had outlook in non cached mode, retrieving and opening each email, then moving it to a processed folder was arduous to say the least. When I had it in cached mode, of course I had to write code to ensure it had bothered to sync everything so I had uptodate info before I started.

When its cached you can open many many mail items at the same time, and parallel process, where as often in non cached mode it will stop you at around 32! and its idea of open (and ours) differ.

So, I also tried a imap class, sheesh lets never talk of that again what a mistake.

If you have some code, maybe we can help? If you dont have cached mode, I can probably dig out my how I forced it to sync everything code, it wasnt as nice and simple (I may have missed somethhing) as I thought but it works very reliably and now processes all the backup emails I get..

Recommend

  • Displaying image retrieved from database to image control
  • cannot load gems in test environment
  • Exposing an enum in a QML signal
  • Rx produce and consume on different threads
  • C# Networkstream reads nothing
  • Autohotkey script running program with command line arguments
  • ASP.NET C# upload MemoryStream content via FTPwebRequest issue
  • php show all images in directory and sort by last modified
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • C# - Most efficient way to iterate through multiple arrays/list
  • Passing variable arguments using PowerShell's Start-Process cmdlet
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • How can I include If-None-Match header in HttpRequestMessage
  • Application level floating views with navigation in Android
  • Row to Column conversion in Talend
  • jQuery Orbit - How to make a Random Slideshow?
  • SAXReader not re-ecape characters
  • Do I need to reset a Perl hash index?
  • Use of this Javascript
  • Bad request using file_get_contents for PUT request in PHP
  • Checking free space on FTP server
  • What is Eclipse's Declaration View used for?
  • Fetching methods from BroadcastReceiver to update UI
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Symfony2: How to get request parameter
  • Jquery - Jquery Wysiwyg return html as a string
  • GridView Sorting works once only
  • R: gsub and capture
  • SVN: Merging two branches together
  • AT Commands to Send SMS not working in Windows 8.1
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • SetUp method failed while running tests from teamcity
  • WPF Applying a trigger on binding failure
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • How does Linux kernel interrupt the application?
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Append folder name and increment by 1 using batch script
  • git trying to push non-existent file … after clearing cache