Outlook MailItem as Stream

守給你的承諾、 提交于 2020-01-04 03:57:26

问题


Is it possible to return a MailItem directly as a Stream? (MailItem from Microsoft.Office.Interop.Outlook)

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?

(Edit due to comments: 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)


回答1:


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..



来源:https://stackoverflow.com/questions/11227797/outlook-mailitem-as-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!