S
Steve A.
Greetings
I want to access message.fields to search the internet headers for a message.
I'm using code I have found on the net, and don't understand MAPI or CDO
very well.
I believe the The code fails at GetMessage becuse the objSession is not
initialised properly: Any suggestions?
I have
Function GetCDOItemFromOL(objOLItem As Object) As MAPI.Message
Dim objSession As MAPI.Session
Dim objApp As Outlook.Application
Dim strEntryID As String
Dim strStoreID As String
Set objApp = CreateObject("Outlook.Application")
strEntryID = objOLItem.EntryID
strStoreID = objOLItem.Parent.StoreID
objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False
Set GetCDOItemFromOL = objSession.GetMessage(strEntryID, strStoreID)
objSession.Logoff
Set objSession = Nothing
End Function
Sub RuleScript(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim objCDOMsg As MAPI.Message
Dim InternetHeaders As String
Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E
Set objCDOMsg = GetCDOItemFromOL(MyMail)
InternetHeaders = objCDOMsg.Fields(CdoPR_TRANSPORT_MESSAGE_HEADERS)
MsgBox "Mail message arrived Internet Headers Are : " & InternetHeaders
Set objCDOMsg = Nothing
Set olMail = Nothing
Set olNS = Nothing
End Sub
I want to access message.fields to search the internet headers for a message.
I'm using code I have found on the net, and don't understand MAPI or CDO
very well.
I believe the The code fails at GetMessage becuse the objSession is not
initialised properly: Any suggestions?
I have
Function GetCDOItemFromOL(objOLItem As Object) As MAPI.Message
Dim objSession As MAPI.Session
Dim objApp As Outlook.Application
Dim strEntryID As String
Dim strStoreID As String
Set objApp = CreateObject("Outlook.Application")
strEntryID = objOLItem.EntryID
strStoreID = objOLItem.Parent.StoreID
objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False
Set GetCDOItemFromOL = objSession.GetMessage(strEntryID, strStoreID)
objSession.Logoff
Set objSession = Nothing
End Function
Sub RuleScript(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim objCDOMsg As MAPI.Message
Dim InternetHeaders As String
Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E
Set objCDOMsg = GetCDOItemFromOL(MyMail)
InternetHeaders = objCDOMsg.Fields(CdoPR_TRANSPORT_MESSAGE_HEADERS)
MsgBox "Mail message arrived Internet Headers Are : " & InternetHeaders
Set objCDOMsg = Nothing
Set olMail = Nothing
Set olNS = Nothing
End Sub