error out of CDO script 
Author Message
 error out of CDO script

I'm trying to fish out the SMTP headers out of an Outlook email with the
following code. When I run it, Outlook puts up the "security" warning that a
script is trying to access your email. What am I doing wrong?

- Pito

Sub CustomMailMessageRule(Item As Outlook.MailItem)
    MsgBox "Mail message arrived: " & Item.Subject
    Dim oCDO 'As MAPI.session
    Dim oMsg 'As MAPI.Message
    Dim oFields 'As MAPI.Fields
    Dim oField 'As MAPI.Field
    Dim sHeaders 'As String
    Dim sEntryID 'As String
    Dim sStoreID 'As String
    Dim oInspector 'As Outlook.Inspector

    Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

    On Error Resume Next

    Set oInspector = Item.GetInspector

    If Item.EntryID <> "" Then
        oInspector.ShowFormPage ("Internet Headers")
        Set oCDO = CreateObject("MAPI.Session")
        oCDO.Logon "", "", False, False

        sEntryID = Item.EntryID
        sStoreID = Item.Parent.StoreID

        Set oMsg = oCDO.GetMessage(sEntryID, sStoreID)
        Set oFields = oMsg.Fields
        Set oField = oFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS)
        sHeaders = oField.Value

    Item.UserProperties("InternetHeaders").Value = sHeaders
        oCDO.Logoff
    Else
        oInspector.HideFormPage ("Internet Headers")
    End If
    MsgBox "Mail header: " & sHeaders

    Set oInspector = Nothing
    Set oField = Nothing
    Set oFields = Nothing
    Set oMsg = Nothing
    Set oCDO = Nothing
    End Sub



Thu, 14 Jul 2005 06:39:52 GMT  
 error out of CDO script
You're doing nothing wrong. That field is protected by the "object model guard" because it contains information that could be used by a virus to harvest email addresses. See http://www.slipstick.com/outlook/esecup.htm#autosec.

I haven't tried it with Redemption (http://www.dimastr.com/redemption/), but would expect it to work without the prompt.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> I'm trying to fish out the SMTP headers out of an Outlook email with the
> following code. When I run it, Outlook puts up the "security" warning that a
> script is trying to access your email. What am I doing wrong?

>     Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

>         Set oField = oFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS)



Thu, 14 Jul 2005 07:00:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Script Error Or No Script Error That Is The Question

2. CDO in Outlook script

3. Does CDO Script get run when synchronising

4. university EMR send outs

5. on the outs

6. Learning the ins and outs of Peek and Poke

7. How to handle print outs in VB?

8. Filesystem Time outs

9. Session Variable Time-outs

10. Time-outs

11. Need help with time outs

12. Seeking CDO object reference with correlated CDO PropTags / constants

 

 
Powered by phpBB® Forum Software