![]() |
How to determine whether a message was inbound or outbound
Given a mailItem which has .Sent = True, I want to determine whether it
was outbound (ie sent from this mailbox), or inbound (ie sent to this mailbox). I can't rely on the location of the message, because it may have been moved from the Inbox or from Sent Items. I'm also not keen on using the sender/recipient addresses, because of the possibility of someone changing their sender address, or sending an email to themselves. Testing for the presence of PR_RECEIVED_BY_ADDRTYPE seems to work: Public Function IsInboundMessage(itm As Outlook.MailItem) As Boolean Dim ssn As New MAPI.Session Dim msg As MAPI.Message Dim typ As String ssn.Logon , , False, False, 0 ' Use the existing Outlook session Set msg = ssn.GetMessage(itm.EntryID, itm.Parent.StoreID) On Error Resume Next typ = msg.Fields(CdoPR_RECEIVED_BY_ADDRTYPE).Value If Err.Number 0 Then Err.Clear IsInboundMessage = False Else IsInboundMessage = True End If On Error GoTo 0 ssn.Logoff Set ssn = Nothing Set msg = Nothing End Function Is this the right way to do this? And is it reliable? Thanks. Andy Bowles |
How to determine whether a message was inbound or outbound
Am 14 Sep 2006 05:41:14 -0700 schrieb Andy Bowles:
That´s right and reliable, sent items do not have any pr_received* properties. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Given a mailItem which has .Sent = True, I want to determine whether it was outbound (ie sent from this mailbox), or inbound (ie sent to this mailbox). I can't rely on the location of the message, because it may have been moved from the Inbox or from Sent Items. I'm also not keen on using the sender/recipient addresses, because of the possibility of someone changing their sender address, or sending an email to themselves. Testing for the presence of PR_RECEIVED_BY_ADDRTYPE seems to work: Public Function IsInboundMessage(itm As Outlook.MailItem) As Boolean Dim ssn As New MAPI.Session Dim msg As MAPI.Message Dim typ As String ssn.Logon , , False, False, 0 ' Use the existing Outlook session Set msg = ssn.GetMessage(itm.EntryID, itm.Parent.StoreID) On Error Resume Next typ = msg.Fields(CdoPR_RECEIVED_BY_ADDRTYPE).Value If Err.Number 0 Then Err.Clear IsInboundMessage = False Else IsInboundMessage = True End If On Error GoTo 0 ssn.Logoff Set ssn = Nothing Set msg = Nothing End Function Is this the right way to do this? And is it reliable? Thanks. Andy Bowles |
All times are GMT +1. The time now is 09:01 PM. |
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