Setting HTMLBODY extremely slow
-
Wednesday, June 13, 2012 8:05 PM
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
Thanks
All Replies
-
Wednesday, June 13, 2012 8:23 PM
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!
-
Thursday, June 14, 2012 4:21 AM
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.
-
Thursday, June 14, 2012 6:23 AMhtml means structured text, like everyhing must be mebedded inside <html> tags. Are you sure that you are not concatenating 2 strings that each has own full html structure?
-
Thursday, June 14, 2012 6:41 AM
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.
-
Thursday, June 14, 2012 6:51 AMhow big is that html? are you sure you are not splitting it inside tag declaration?
-
Thursday, June 14, 2012 9:53 PM
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
-
Friday, June 15, 2012 4:32 AM
Do you see the same problem if you do the following?
olMailItem.HTMLBody = olMailItem.HTMLBody
Dmitry Streblechenko (MVP) http://www.dimastr.com/redemption
Redemption - what the Outlook
Object Model should have been
Version 5.3 is now available!
-
Monday, July 16, 2012 5:38 PMSorry for the delay. Yes, it takes the same amount of time. Maybe what I'll try is deleting parts of the message to see what eventually speeds things up. Not sure if the images create the delay.

