选择ActiveExplorer中的邮件项



我编写了一个宏来打开Outlook搜索结果中所选电子邮件的路径。

在打开的文件夹中没有自动标记电子邮件,所以我在"activeexplorer"中搜索电子邮件。使用。display,我可以打开电子邮件,但是我无法在"activeexplorer"中选择找到的电子邮件。

Public Sub MailOrdnerPfad()
Dim obj As Object
Dim Ordner As Outlook.MAPIFolder
Dim Betreff As String
Dim Mail As MailItem
Set obj = Application.ActiveWindow
If TypeOf obj Is Outlook.Inspector Then
Set obj = obj.CurrentItem
Else
Set obj = obj.Selection(1)
End If
Betreff = obj.ConversationTopic
Set Ordner = obj.Parent
Set Application.ActiveExplorer.CurrentFolder = Ordner
For Each Mail In Ordner.Items
If Mail.ConversationTopic = Betreff Then
Mail.Display
Exit For
End If
Next
End Sub

清除原来的选择,然后添加找到的项。

Option Explicit

Public Sub MailOrdnerPfad()
Dim obj As Object

Dim Ordner As Folder
Dim ordItem As Object

Dim Betreff As String
Dim myMail As MailItem
Set obj = ActiveWindow
If TypeOf obj Is Inspector Then
Set obj = obj.CurrentItem
Else
Set obj = obj.Selection(1)
End If

If obj.Class = olMail Then

Betreff = obj.ConversationTopic
Debug.Print "Betreff: " & Betreff

Set Ordner = obj.Parent
Set ActiveExplorer.CurrentFolder = Ordner
Debug.Print "Ordner.: " & Ordner

For Each ordItem In Ordner.items

If ordItem.Class = olMail Then

Set myMail = ordItem

Debug.Print "myMail.ConversationTopic: " & myMail.ConversationTopic

If myMail.ConversationTopic = Betreff Then

ActiveExplorer.ClearSelection
' myMail.Display
ActiveExplorer.AddToSelection myMail

Exit For
End If
End If
Next

End If

End Sub

相关内容

  • 没有找到相关文章

最新更新