![]() |
MailItem.SaveAs encoding characters wrong from HTML message
Hello! It was suggested in the MSDN forums that I post my question here.
It's not VBA specific, though it pertains to Outlook interop with Visual Basic. If there's a better place to post this, please let me know. In a Visual Basic .NET 1.1 application which I wrote and have been maintaining, I'm observing a strange behavior on one system (but not the other systems I've installed it on). The application uses Outlook interop to communicate with Outlook 2003 and saves select email messages for further processing. When saving messages, based on the MailItem's BodyFormat I call the MailItem's SaveAs method with the matching Outlook.OlSaveAsType parameter. For instance, and with some code removed for clarity: If curItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olHTML) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatUnspecified Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) End If I haven't had problems so far saving rich text messages as plain text, and anything unspecified getting saved as plain text works fine for my purposes. The problem is that on this particular workstation when an HTML message is saved there are character encoding problems in the resulting html file. These encoding problems only affect certain punctuation such as em dash, apostrophe, and tildes. The html file resulting from the MailItem.SaveAs has, for example � instead of – . If I interactively go into Outlook and choose File Save As, selecting html, the characters in question are saved properly. I am left feeling that because identical releases of the software on different computers are behaving differently that it should be a problem with some system setting on the computer in question. The version of the OS (XP Pro) and Outlook (2003, SP3) are the same across these computers (though i still need to get the specific version numbers looked up). Does anyone have any thoughts on what would affect the formatting of the SaveAs HTML output like this? |
MailItem.SaveAs encoding characters wrong from HTML message
Is this with all HTML messages on that computer or only some messages?
What is the default character set and font on the problem computer? The code page? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "MattS" wrote in message ... Hello! It was suggested in the MSDN forums that I post my question here. It's not VBA specific, though it pertains to Outlook interop with Visual Basic. If there's a better place to post this, please let me know. In a Visual Basic .NET 1.1 application which I wrote and have been maintaining, I'm observing a strange behavior on one system (but not the other systems I've installed it on). The application uses Outlook interop to communicate with Outlook 2003 and saves select email messages for further processing. When saving messages, based on the MailItem's BodyFormat I call the MailItem's SaveAs method with the matching Outlook.OlSaveAsType parameter. For instance, and with some code removed for clarity: If curItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olHTML) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatUnspecified Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) End If I haven't had problems so far saving rich text messages as plain text, and anything unspecified getting saved as plain text works fine for my purposes. The problem is that on this particular workstation when an HTML message is saved there are character encoding problems in the resulting html file. These encoding problems only affect certain punctuation such as em dash, apostrophe, and tildes. The html file resulting from the MailItem.SaveAs has, for example � instead of – . If I interactively go into Outlook and choose File Save As, selecting html, the characters in question are saved properly. I am left feeling that because identical releases of the software on different computers are behaving differently that it should be a problem with some system setting on the computer in question. The version of the OS (XP Pro) and Outlook (2003, SP3) are the same across these computers (though i still need to get the specific version numbers looked up). Does anyone have any thoughts on what would affect the formatting of the SaveAs HTML output like this? |
MailItem.SaveAs encoding characters wrong from HTML message
Ken,
Thank you for your response. I have asked my client to run chcp to determine the active code page on both the problematic workstation and on one working properly. I will post the result here when I have it. I did some digging and could not find out how to determine the default character set or font on an XP computer. Can you offer any tips? Finally, if it helps, I've received some version info: Problem computer: XP Pro, version 2002, SP 2 Outlook 2003 (11.8206.8202) SP3 Good computer: XP Pro, version 2002, SP 2 Outlook 2003 (11.8118.8132) SP2 Thank you again for your help. Matt "Ken Slovak - [MVP - Outlook]" wrote: Is this with all HTML messages on that computer or only some messages? What is the default character set and font on the problem computer? The code page? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "MattS" wrote in message ... Hello! It was suggested in the MSDN forums that I post my question here. It's not VBA specific, though it pertains to Outlook interop with Visual Basic. If there's a better place to post this, please let me know. In a Visual Basic .NET 1.1 application which I wrote and have been maintaining, I'm observing a strange behavior on one system (but not the other systems I've installed it on). The application uses Outlook interop to communicate with Outlook 2003 and saves select email messages for further processing. When saving messages, based on the MailItem's BodyFormat I call the MailItem's SaveAs method with the matching Outlook.OlSaveAsType parameter. For instance, and with some code removed for clarity: If curItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olHTML) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatRichText Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) ElseIf curItem.BodyFormat = Outlook.OlBodyFormat.olFormatUnspecified Then curItem.SaveAs(fn, Outlook.OlSaveAsType.olTXT) End If I haven't had problems so far saving rich text messages as plain text, and anything unspecified getting saved as plain text works fine for my purposes. The problem is that on this particular workstation when an HTML message is saved there are character encoding problems in the resulting html file. These encoding problems only affect certain punctuation such as em dash, apostrophe, and tildes. The html file resulting from the MailItem.SaveAs has, for example � instead of – . If I interactively go into Outlook and choose File Save As, selecting html, the characters in question are saved properly. I am left feeling that because identical releases of the software on different computers are behaving differently that it should be a problem with some system setting on the computer in question. The version of the OS (XP Pro) and Outlook (2003, SP3) are the same across these computers (though i still need to get the specific version numbers looked up). Does anyone have any thoughts on what would affect the formatting of the SaveAs HTML output like this? |
MailItem.SaveAs encoding characters wrong from HTML message
I'm not sure about the default code page but the fonts are set for the
desktop and used throughout Windows. Right-click on the desktop, select Properties, Appearance tab, Advanced button. Each desktop element has an associated font if it's an element that supports text. For the code page there's always google search. You can also go to www.slipstick.com and search for Outlook 2002 versions and see if any fixes are listed that are relevant between the versions you listed. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "MattS" wrote in message ... Ken, Thank you for your response. I have asked my client to run chcp to determine the active code page on both the problematic workstation and on one working properly. I will post the result here when I have it. I did some digging and could not find out how to determine the default character set or font on an XP computer. Can you offer any tips? Finally, if it helps, I've received some version info: Problem computer: XP Pro, version 2002, SP 2 Outlook 2003 (11.8206.8202) SP3 Good computer: XP Pro, version 2002, SP 2 Outlook 2003 (11.8118.8132) SP2 Thank you again for your help. Matt |
All times are GMT +1. The time now is 05:03 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com