本文介绍了使用ConversationID在Outlook中显示电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Outlook VBA脚本,是否可以基于从Mailitem类获取的唯一标识符显示电子邮件?

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

即我遍历一个文件夹,并用SenderName,Subject,SentOn和ConversationID填充一个列表框.

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

该列表框位于用户窗体中,我希望能够基于ConversationID显示电子邮件.我不确定如何实际执行此操作,但是也许是这样的:

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

推荐答案

我基于以下内容找到了答案: https://stackoverflow.com/a/7439554/757856

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

基本上,您必须使用MailItem.EntryID,而不是ConversationID

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

我使用了与上面链接相同的代码,但是我使用了后期绑定而不是早期绑定.给出EntryID的以下代码将打开Outlook电子邮件:

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

这篇关于使用ConversationID在Outlook中显示电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:38