Q
QDC_Juha
I have a large number of mail messages which have been written in Finnish,
but have been marked with a US-ASCII code page. The result is that some of
the characters are displayed incorrectly, e.g. "ä" is shown as a "d".
It is possible to correct this error in Outlook by opening the message,
setting the code page manually from the View>>Encoding menu and then saving
the message. Instead of doing this to about 500 messages by hand, I tried to
write a short program to do it.
The result of running the code below is that the code page of all messages
in my "Macro" folder is set to iso_8859_1 (as I want to happen).
Unfortunately, when I open the messages they are still displayed incorrectly.
However, if I open the View menu and look at the code page settings, they
are correctly set to "Western European (ISO)" as I want them to be. I.e. the
property change is successful, but the view of the message doesn't change.
What is it that I am missing ? Changing the code page manually from the
menu affects the message view immediately, while doing it programatically
does not cause the view to change. Is there something in the mail message
view (Inspector object) that persists ? Or should I be changing some other
property than the InternetCodepage ?
Thanks for all answers,
Juha
Sub SetMessageCodePages()
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMessages As Outlook.Items
Dim myMessage As Object
Const USASCII As Long = 20127
Const iso_8859_1 As Long = 28591
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myInboxFolder = _
myNamespace.GetDefaultFolder(olFolderInbox)
Set myRootFolder = myInboxFolder.Parent
Set myMacroFolder = myRootFolder.Folders("Macro")
Set myMessages = myMacroFolder.Items
For Each myMessage In myMessages
myMessage.InternetCodepage = iso_8859_1
Debug.Print "Code page has been set to:" &
myMessage.InternetCodepage
myMessage.Close olSave
Next
End Sub
but have been marked with a US-ASCII code page. The result is that some of
the characters are displayed incorrectly, e.g. "ä" is shown as a "d".
It is possible to correct this error in Outlook by opening the message,
setting the code page manually from the View>>Encoding menu and then saving
the message. Instead of doing this to about 500 messages by hand, I tried to
write a short program to do it.
The result of running the code below is that the code page of all messages
in my "Macro" folder is set to iso_8859_1 (as I want to happen).
Unfortunately, when I open the messages they are still displayed incorrectly.
However, if I open the View menu and look at the code page settings, they
are correctly set to "Western European (ISO)" as I want them to be. I.e. the
property change is successful, but the view of the message doesn't change.
What is it that I am missing ? Changing the code page manually from the
menu affects the message view immediately, while doing it programatically
does not cause the view to change. Is there something in the mail message
view (Inspector object) that persists ? Or should I be changing some other
property than the InternetCodepage ?
Thanks for all answers,
Juha
Sub SetMessageCodePages()
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myMessages As Outlook.Items
Dim myMessage As Object
Const USASCII As Long = 20127
Const iso_8859_1 As Long = 28591
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myInboxFolder = _
myNamespace.GetDefaultFolder(olFolderInbox)
Set myRootFolder = myInboxFolder.Parent
Set myMacroFolder = myRootFolder.Folders("Macro")
Set myMessages = myMacroFolder.Items
For Each myMessage In myMessages
myMessage.InternetCodepage = iso_8859_1
Debug.Print "Code page has been set to:" &
myMessage.InternetCodepage
myMessage.Close olSave
Next
End Sub