Monday, November 1, 2021

Finding an item by its unique entry in outlook using VBA

 Sub finditem_byuniqueentry()




Dim olApp, olAccts, olInspect, ns As Object
Dim myStoreID, myEntryID As String

Set olApp = CreateObject("Outlook.Application")
Dim olFolder As outlook.MAPIFolder
Set ns = outlook.GetNamespace("MAPI")
Set olFolder = ns.Folders("allsourav@hotmail.com").Folders("Sent Items")

myStoreID = olFolder.StoreID
myEntryID = "00000000252E983297E98F47B95403F4214B120D0700F0072D28E9944441ACCC552F18B27F6A0000000001090000F0072D28E9944441ACCC552F18B27F6A00038DE5ED3E0000"
Set foundmail = ns.GetItemFromID(myEntryID, myStoreID)

Debug.Print foundmail.Subject, foundmail.SenderName, foundmail.ReceivedTime



End Sub

No comments:

Post a Comment