I have a VSTO 2010 project that manipulates the Body of a message. The following statement sometimes takes 8 seconds to process for large messages. Any reason why that would be? Is there a workaround to speed this up?
olMailItem.HTMLBody = sHTMLBody1 & sHTMLBody2
You cannot concatenate 2 HTML bodies and produce a valid HTML body; they must be merged.
Where do sHTMLBody1 and sHTMLBody2 come from and what are their values?
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.3 is now available!
sHTMLBody1 and 2 are STRINGS that are set as follows:
Dim sHTMLBody1 as string
sHTMLBody1 = olMailItem.HTMLBody.Substring(0, iStart)
Processing then takes place on those strings before moving it back to the MailItem. All works well, just extremely slow in some instances.
That should not be the case. sHTMLBody2 is set as follows:
sHTMLBody2 = olMailItem.HTMLBody.Substring(iStart)
I would think if there was an issue, the message would mess up. I have viewed the outlook message source in the past and it looks as it should. Not sure why taking the current body and splitting it and then moving it back would create such a delay. There must be some backend logic Outlook is employing at that point. Not sure what though.
The html is intact. Size of the message is 125K. Just executing the following statements causes the time lag:
Dim sHTMLBody1 as string Dim sHTMLBody2 as string Dim olMailItem As Outlook.MailItem = DirectCast(item, Outlook.MailItem) sHTMLBody1 = olMailItem.HTMLBody.Substring(0, iStart) sHTMLBody2 = olMailItem.HTMLBody.Substring(iStart) olMailItem.HTMLBody = sHTMLBody1 & sHTMLBody2 ' Delay
- Edited by J Wagner Thursday, June 14, 2012 9:56 PM