Outlook.MailItem.HTMLBody doesn't refresh when updated under inline response

梦想的初衷 提交于 2020-01-06 07:11:55

问题


When setting MailItem.HTMLBody for a inline response, sometimes the updated body never gets displayed. If I make a call to MailItem.Save(), sometimes it shows up but only under saved draft preview. Does anyone know of a way to force the updated HTMLBody to render?

Some addition findings:

  • For emails with only plain text (but MailItem.BodyFormat is OlBodyFormat.olFormatHTML), this always happens.
  • For emails with HTML content and images, this happens if user chooses to download external content when replying
  • For emails with HTML content and images, this does NOT happen if user chooses not to download external content

I have tried to use different routes to get the MailItem through the explorer and they all lead to the same results. Here are the different methods I've tried, in case I missed anything:

  1. Through Outlook.Application.Explorers.NewExplorer event handler arg
  2. Through ActiveInlineResponse property

explorer = OutlookApp.ActiveExplorer();

response = explorer.ActiveInlineResponse;

  1. Through InvokeMember("ActiveInlineResponse"...

explorer = OutlookApp.ActiveExplorer();

response = explorer.GetType().InvokeMember("ActiveInlineResponse", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public, null, explorer, null) as MailItem;

Environment:

  • Office version: 16.0.10827.20118
  • Windows 10
  • Office 2007 Primary Interop
  • VSTO 2010

回答1:


For those interested, I found what causes this behavior. It doesn't fully explain the underlying problem but at least we have a workaround.

Prior to setting HTMLBody, we accessed the document to retrieve selected text through Document doc = MailItem.GetInspector.WordEditor.

Changing this to Document doc = ActiveExplorer.ActiveInlineResponseWordEditor eliminated the issue described above.



来源:https://stackoverflow.com/questions/53010824/outlook-mailitem-htmlbody-doesnt-refresh-when-updated-under-inline-response

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