How to uniquely identify an Outlook email as MailItem.EntryID changes when email is moved

后端 未结 3 878
忘了有多久
忘了有多久 2021-01-14 08:38

My company uses a single email address for customers to send requests and orders to. we created an Access database that import emails into a table. The table creates it\'s o

3条回答
  •  無奈伤痛
    2021-01-14 09:08

    Here is VBA code tested in MS Access 2013 to extract the PR_SEARCH_KEY from an Outlook.MailItem and convert to a string:

    Public Function strGetMailItemUniqueId( _
        olMailItem As Outlook.MailItem _
    ) As String
        Dim PR_SEARCH_KEY As String
        PR_SEARCH_KEY = "http://schemas.microsoft.com/mapi/proptag/0x300B0102"
    
        Dim olPA As Outlook.PropertyAccessor
        Set olPA = olMailItem.PropertyAccessor
    
        Dim vBinary As Variant
        vBinary = olPA.GetProperty(PR_SEARCH_KEY)
    
        strGetMailItemUniqueId = olPA.BinaryToString(vBinary)
    End Function
    

提交回复
热议问题