Gruzzles
Gruzzles

Reputation: 291

Display email in Outlook by using ConversationID

Using Outlook VBA script, is it possible to display an email based on a unique identifier taken from the Mailitem class?

i.e. I loop through a folder and populate a listbox with SenderName, Subject, SentOn, and ConversationID.

For i = oFolder.Items.Count To 1 Step -1
    Me.ListBox1.AddItem oFolder.Items.Item(i).ConversationID
Next i

The listbox is in a userform, and I want to be able to display the email based on the ConversationID. I am unsure about how to actually do this, but maybe it is something like this:

Dim Msg As Outlook.MailItem
Set Msg = oFolder.GetObjectFromConversationID(Me.ListBox1.Value).Display
Msg.Display

Upvotes: 2

Views: 4784

Answers (1)

Gruzzles
Gruzzles

Reputation: 291

I found the answer based off of this: https://stackoverflow.com/a/7439554/757856

Basically, You have to use MailItem.EntryID, not ConversationID

I used the same code as in the link above, but I used late binding instead of early. The following code will open an Outlook email given the EntryID:

Dim oNamespace As Object
Dim Msg As Object
Set oNamespace = oOlApp.GetNamespace("MAPI")
Set Msg = oNamespace.GetItemFromID(EntryID)
Msg.Display

Upvotes: 6

Related Questions