Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Outlook, HTML and CDO
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Outlook, HTML and CDO
Divers
Thread ID:
00797784
Message ID:
00797784
Vues:
74
Hi, I need to convert some HTML messages in Outlook 2000 to plain text.
I found this by Ken Slovak that seems to indicate that something called
CDO can be used for this purpose. Does anyone know how to use this with
VFP and Outlook?
Thanks
STEVe

Here Ken Slovak write that to remove HTML code ...

The only way to do that is to use CDO code. You have to get the
message Body as a string and then clear all the RTF property tag
fields and then put the Body string in the Text field.

Here is some VBA code that does that in the Item_Add event handler, it
can be adapted to work as form code with the appropriate changes:

Private Sub oInbox_ItemAdd(ByVal Item As Object)
Dim oCDO As MAPI.Session
Dim oCDOMsg As MAPI.Message
Dim oField As MAPI.Field

Dim sEntry As String
Dim sMsg As String

Const CdoPR_HTML_BODY = &H1013001E
Const CdoPR_HTMLPLAIN_BODY = &H7101001F

If TypeName(Item) = "MailItem" Then
On Error Resume Next

If Item.HTMLBody <> vbNullString Then
sMsg = Item.Body
Item.Body = sMsg
Item.Save

sEntry = Item.EntryID

Set Item = Nothing

Set oCDO = CreateObject("MAPI.Session")
oCDO.Logon "", "", False, False
Set oCDOMsg = objCDO.GetMessage(sEntry)

sMsg = oCDOMsg.Text
oCDOMsg.Fields(CdoPR_RTF_COMPRESSED).Delete
oCDOMsg.Fields(CdoPR_RTF_IN_SYNC).Delete
oCDOMsg.Fields(CdoPR_RTF_SYNC_BODY_COUNT).Delete
oCDOMsg.Fields(CdoPR_RTF_SYNC_BODY_CRC).Delete
oCDOMsg.Fields(CdoPR_RTF_SYNC_BODY_TAG).Delete
oCDOMsg.Fields(CdoPR_RTF_SYNC_PREFIX_COUNT).Delete
oCDOMsg.Fields(CdoPR_RTF_SYNC_TRAILING_COUNT).Delete

Set oField = oCDOMsg.Fields(CdoPR_HTML_BODY)
If Err = 0 Then
oCDOMsg.Fields(CdoPR_HTML_BODY).Delete
Else
Err.Clear
End If

Set oField = oCDOMsg.Fields(CdoPR_HTMLPLAIN_BODY)
If Err = 0 Then
oCDOMsg.Fields(CdoPR_HTMLPLAIN_BODY).Delete
Else
Err.Clear
End If

oCDOMsg.Text = strMsg
oCDOMsg.Update
objCDO.Logoff
End If
End If

Set oField = Nothing
Set oCDO = Nothing
Set oCDOMsg = Nothing
End Sub
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform