Outlook and encoding charset

  • Thread starter Thread starter d.gallone
  • Start date Start date
D

d.gallone

Hello,
I use VB6 and outlook 2002 and I want to know how to access at the
encoding charset (utf-8 or iso,...) information of a Outlook.MailItem ?

Is it accessible in the mailitem.Itemproperties of the mail ?


Thanks,
David GALLONE
 
That information is within the Internet transport headers, if the email was
sent using SMTP. It would be in a header line titled "charset". That
property (PR_TRANSPORT_MESSAGE_HEADERS) is not available to the Outlook
object model. You'd have to get it using Extended MAPI (C++ or Delphi code
only) or CDO 1.21 (where it would trigger the security prompts).

The message headers would be returned to you as a text string, you'd have to
parse for "charset" and what follows.
 
Hello,
Thanks for the information.
When i use the property PR_TRANSPORT_MESSAGE_HEADERS I've the following
error :
Err number = -2147221233 [Collaboration Data Objects -
[MAPI_E_NOT_FOUND(8004010F)]]

Here is a part of my sourcecode :
....
Dim orecip
Dim sCharSet As String
Set orecip = oCDOSession.GetMessage(oCurMail.EntryID,
oCurMail.Parent.StoreID)
sCharSet = orecip.Fields(PR_TRANSPORT_MESSAGE_HEADERS)

Any idea ?
Thanks David GALLONE
 
Do you have a declaration of that property tag? It should evaluate to
0x007D001E and it's only there for received messages.
 
Const PR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

Is it also valid for mail received from the Exchange server or only for
external mail ?

David GALLONE
 
Only external mail. Mail within an Exchange org doesn't go over the
Internet.
 
Thanks, and is it possible to check the charset of the "internal" mail
(Exchange) ?

David GALLONE
 
Yeah, but you have to be sneaky about it <g>.

You can look at the PR_RTF_COMPRESSED (0x10090102) tag and parse that. The
codepage and charset are in there in a form something like this:

{\rtf1\ansi\ansicpg1252\fromhtml1 \deff0{\fonttbl
{\f0\fswiss Arial;}
{\f1\fmodern Courier New;}
{\f2\fnil\fcharset2 Symbol;}
{\f3\fmodern\fcharset0 Courier New;}
{\f4\fswiss Arial;}}
{\colortbl\red0\green0\blue0;\red0\green0\blue255;}
\uc1\pard\plain\deftab360 \f0\fs24
{\*\htmltag19 <html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">}
{\*\htmltag2 \par }
{\*\htmltag2 \par }
{\*\htmltag34 <head>}
{\*\htmltag1 \par }
{\*\htmltag1 \par }
{\*\htmltag161 <meta name=Generator content="Microsoft Word 11 (filtered
medium)">}
{\*\htmltag1 \par }
{\*\htmltag241 <style>}
{\*\htmltag241 \par <!--\par /* Style Definitions */\par p.MsoNormal,
li.MsoNormal, div.MsoNormal\par \tab \{margin:0in;\par \tab
margin-bottom:.0001pt;\par \tab font-size:12.0pt;\par \tab
font-family:"Times New Roman";\}\par a:link, span.MsoHyperlink\par \tab
\{color:blue;\par \tab text-decoration:underline;\}\par a:visited,
span.MsoHyperlinkFollowed\par \tab \{color:purple;\par \tab
text-decoration:underline;\}\par span.EmailStyle17\par \tab
\{mso-style-type:personal-compose;\par \tab font-family:Arial;\par \tab
color:windowtext;\}\par @page Section1\par \tab \{size:8.5in 11.0in;\par
\tab margin:1.0in 1.25in 1.0in 1.25in;\}\par div.Section1\par \tab
\{page:Section1;\}\par -->\par }
{\*\htmltag249 </style>}
{\*\htmltag1 \par }
{\*\htmltag1 \par }
{\*\htmltag41 </head>}
{\*\htmltag2 \par }
{\*\htmltag2 \par }
{\*\htmltag50 <body lang=EN-US link=blue vlink=purple>}\htmlrtf \lang1033
\htmlrtf0
{\*\htmltag0 \par }
{\*\htmltag0 \par }
{\*\htmltag96 <div class=Section1>}\htmlrtf {\htmlrtf0
{\*\htmltag0 \par }
{\*\htmltag0 \par }
{\*\htmltag64 <p class=MsoNormal>}\htmlrtf {\htmlrtf0
{\*\htmltag148 <font size=2 face=Arial>}\htmlrtf {\fs20 \f4 \htmlrtf0
{\*\htmltag84 <span style='font-size:10.0pt;\par
font-family:Arial'>}\htmlrtf {\htmlrtf0 test
{\*\htmltag244 <o:p>}
{\*\htmltag252 </o:p>}
{\*\htmltag92 </span>}\htmlrtf }\htmlrtf0
{\*\htmltag156 </font>}\htmlrtf }\htmlrtf0 \htmlrtf\par}\htmlrtf0
\htmlrtf \par
\htmlrtf0
{\*\htmltag72 </p>}
{\*\htmltag0 \par }
{\*\htmltag0 \par }
{\*\htmltag104 </div>}\htmlrtf }\htmlrtf0
{\*\htmltag0 \par }
{\*\htmltag0 \par }
{\*\htmltag58 </body>}
{\*\htmltag2 \par }
{\*\htmltag2 \par }
{\*\htmltag27 </html>}
{\*\htmltag3 \par }}
 
Back
Top