H
Howard Kaikow
I modified the code in MSFT KB article 194870 to choose all messages. I give
the code below.
I placed the code in a class and added a macro to call the code.
However, this causes two messages to appear:
1. AA mesage to select the Profile to be used. This occurs once.
2. The message caused by Outlook SEcurity that could be bypassed if I were
using the EntryID. This occurs for each message.
How can I avoid these messages?
Dim oSession As MAPI.Session
Dim oFolder As Folder
Dim oMsgColl As Messages
Dim oMessage As Message
' Logon to the MAPI session
Set oSession = New MAPI.Session
oSession.Logon
' Get the Inbox folder and its message collection.
Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oMsgColl = oFolder.Messages
' Search through the messages in the Inbox for the Internet
' message. Then use the CdoPR_TRANSPORT_MESSAGE_HEADERS
' (&H7D001E) property tag to retrieve the Internet header.
' If the property doesn't exist(Not a Internet message) you will
' receive a MAPI_E_NOT_FOUND error.
For Each oMessage In oMsgColl
' My modification is the removal of the If and the addition of the On Error
On Error Resume Next
MsgBox oMessage.Fields(&H7D001E) 'Display the header
Err.Clear
Next
' Logoff and cleanup
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oMsgColl = Nothing
Set oFolder = Nothing
the code below.
I placed the code in a class and added a macro to call the code.
However, this causes two messages to appear:
1. AA mesage to select the Profile to be used. This occurs once.
2. The message caused by Outlook SEcurity that could be bypassed if I were
using the EntryID. This occurs for each message.
How can I avoid these messages?
Dim oSession As MAPI.Session
Dim oFolder As Folder
Dim oMsgColl As Messages
Dim oMessage As Message
' Logon to the MAPI session
Set oSession = New MAPI.Session
oSession.Logon
' Get the Inbox folder and its message collection.
Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oMsgColl = oFolder.Messages
' Search through the messages in the Inbox for the Internet
' message. Then use the CdoPR_TRANSPORT_MESSAGE_HEADERS
' (&H7D001E) property tag to retrieve the Internet header.
' If the property doesn't exist(Not a Internet message) you will
' receive a MAPI_E_NOT_FOUND error.
For Each oMessage In oMsgColl
' My modification is the removal of the If and the addition of the On Error
On Error Resume Next
MsgBox oMessage.Fields(&H7D001E) 'Display the header
Err.Clear
Next
' Logoff and cleanup
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oMsgColl = Nothing
Set oFolder = Nothing