将.msg文件附加到HTTP请求
我有一个VSTO程序在Outlook上运行。 该程序在Outlook中的功能区添加按钮 当我单击按钮时,程序下载.msg文件,然后将文件连接到HTTP POST请求中的WS。
因为我不想垃圾用户的计算机。我需要一个想法如何传输.msg文件而不将其暂时保存到用户计算机上的文件夹中,
该程序使用mailItem saveas()函数,
MailItem mailItem = (selObject as MailItem);
mailItem.SaveAs(attchment.full_path, Outlook.OlSaveAsType.olMSG);
谢谢您的帮助
I have a VSTO program the running on outlook.
The program adds button on ribbon in outlook
and when I click on the button the program downloads .MSG file and attach the file to WS in HTTP Post Request.
Because I do not want to trash the user's computer. I need an idea how to transfer the .MSG file without temporarily saving it to a folder on the user's computer
The program uses a MailItem SaveAs() function
MailItem mailItem = (selObject as MailItem);
mailItem.SaveAs(attchment.full_path, Outlook.OlSaveAsType.olMSG);
Thanks for help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Outlook Object模型未提供任何提取消息字节数组的其他方法。因此,将邮件项保存到磁盘上是使用OOM的正确方法。 You may also consider using
EWS
(see不要忘记,一旦传输磁盘上的保存文件。
一种可能的解决方案是默默地转发邮件项目,而不是通过邮政请求上传它们。在这种情况下,您将不必处理磁盘IO操作,从而减慢解决方案。
The Outlook object model doesn't provide any other method for extracting the message's byte array. So, saving the mail item to the disk is a proper way using OOM. You may also consider using
EWS
(see Explore the EWS Managed API, EWS, and web services in Exchange for more information) if you deal with Exchange Server or Graph API.Don't forget to remove the saved file on the disk as soon as it is transferred.
A possible solution is to forward mail items silently instead of uploading them via the POST request. In that case you will not have to deal with disk IO operations which could slow down the solution.
Outlook不允许您这样做,但是您可以将其附加到HTTP请求后立即删除MSG文件。
也没有性能增益 - 机会数据将留在驱动器缓存中,如果磁盘很快被删除,甚至可能不会写入磁盘;而且文件速度较慢,它们仍然比网络快的数量级。
Outlook won't let you do that, but you can delete the MSG file as soon as you attach it to you HTTP request.
There is also no performance gain - chance are the file data will stay in the drive cache and might not even be written to the disk if it is quickly deleted; and as slow as files are, they are still orders of magnitude faster than network.