![]() |
|
Header from Outlook Rule
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 |
Header from Outlook Rule
Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.:
Please donīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Michael, thnaks for your assistance.
Function GetCDOItemFromOL shows message 42 but not 52 ( see msgbox code below) There is no exception or error message but I presume the function silently returns because objSession = CreateObject("MAPI.Session") causes an error MsgBox "Mail message arrived 42" objSession = CreateObject("MAPI.Session") MsgBox "Mail message arrived 52" "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donÂīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Michael
On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donÂīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Am Thu, 18 May 2006 23:23:01 -0700 schrieb Steve A.:
ok, I assume that you donīt have CDO installed. Itīs an optional package from your Outlook or Office CD. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Michael thanks you but Visual Basic Tools - References includes Micrososft CDO 1.21 Library which is ticked and CDO.DLL is on my system , so I think this means that it is installed. "Michael Bauer" wrote: Am Thu, 18 May 2006 23:23:01 -0700 schrieb Steve A.: ok, I assume that you donÂīt have CDO installed. ItÂīs an optional package from your Outlook or Office CD. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donÂīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Am Fri, 19 May 2006 01:55:02 -0700 schrieb Steve A.:
The last thing I could think of why CreateObject("MAPI.Session") fails is that thereīs some kind of a script blocker (Norton Anti Virus)? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael thanks you but Visual Basic Tools - References includes Micrososft CDO 1.21 Library which is ticked and CDO.DLL is on my system , so I think this means that it is installed. "Michael Bauer" wrote: Am Thu, 18 May 2006 23:23:01 -0700 schrieb Steve A.: ok, I assume that you donīt have CDO installed. Itīs an optional package from your Outlook or Office CD. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Michael, Thanks once again but the script runs. The error message I have
discovered is Connection error: 91 Object variable or With block variable not set regards Steve "Michael Bauer" wrote: Am Fri, 19 May 2006 01:55:02 -0700 schrieb Steve A.: The last thing I could think of why CreateObject("MAPI.Session") fails is that thereÂīs some kind of a script blocker (Norton Anti Virus)? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael thanks you but Visual Basic Tools - References includes Micrososft CDO 1.21 Library which is ticked and CDO.DLL is on my system , so I think this means that it is installed. "Michael Bauer" wrote: Am Thu, 18 May 2006 23:23:01 -0700 schrieb Steve A.: ok, I assume that you donÂīt have CDO installed. ItÂīs an optional package from your Outlook or Office CD. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donÂīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Am Fri, 19 May 2006 05:46:01 -0700 schrieb Steve A.:
Autsch, hopefully nobody else has seen this thread :-) For objects you must use the Set statement: Set objSession = CreateObject("MAPI.Session") -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael, Thanks once again but the script runs. The error message I have discovered is Connection error: 91 Object variable or With block variable not set regards Steve "Michael Bauer" wrote: Am Fri, 19 May 2006 01:55:02 -0700 schrieb Steve A.: The last thing I could think of why CreateObject("MAPI.Session") fails is that thereīs some kind of a script blocker (Norton Anti Virus)? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael thanks you but Visual Basic Tools - References includes Micrososft CDO 1.21 Library which is ticked and CDO.DLL is on my system , so I think this means that it is installed. "Michael Bauer" wrote: Am Thu, 18 May 2006 23:23:01 -0700 schrieb Steve A.: ok, I assume that you donīt have CDO installed. Itīs an optional package from your Outlook or Office CD. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Michael On Error GoTo eh eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If Gives the following message Connection error: 91 Object variable or With block variable not set "Michael Bauer" wrote: Am Thu, 18 May 2006 16:59:02 -0700 schrieb Steve A.: Please donīt call InternetHeaders, but InternetHeaders.Value. Why do you know that 'objSession is not initialised properly'? -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- 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 |
Header from Outlook Rule
Michael thanks for your help.
There was another critical error in the code as well. The inclusion of error handling helped flush it out. The other error was a call to objSession.Logoff The code that works for me is show below. The only problem now being the pop-up dialog "A program is trying to access e-mail addresses you have stored in outlook. Do you want to allow this?" Regards Steve A Code for retrieving internet headers in an Outlook Rule: 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 On Error GoTo eh Set objApp = CreateObject("Outlook.Application") strEntryID = objOLItem.EntryID strStoreID = objOLItem.Parent.StoreID Set objSession = CreateObject("MAPI.Session") objSession.Logon , , False, False Set GetCDOItemFromOL = objSession.GetMessage(strEntryID, strStoreID) 'objSession.Logoff == WAS AN ERROR Set objSession = Nothing Exit Function eh: If Err.Number 0 Then MsgBox "Connection error: " & Err.Number & " " & Err.Description Err.Clear Exit Function End If End Function Sub RuleScript(MyMail As 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). Value MsgBox "Mail message arrived Internet Headers Are : " & InternetHeaders Set objCDOMsg = Nothing End Sub |
All times are GMT +1. The time now is 07:12 AM. |
|
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2006 OutlookBanter.com