簡體   English   中英

Outlook VBA鏈接到移動的郵件

[英]Outlook VBA link to moved mail

我想將郵件項目移動到其他文件夾,然后返回指向已移動郵件的鏈接。 不移動,其工作方式如下:

Dim objMail As Outlook.MailItem
Dim sFrag As String
Set objMail = Application.ActiveExplorer.Selection.Item(i_item) 
sFrag =  "<a href='outlook:" + objMail.EntryID + "'>"   + objMail.Subject + "</a>"" 

在這里,字符串sFrag提供了指向有效Outlook元素的正確超鏈接。 如果單擊包含此屬性的超鏈接,則將在Outlook中打開該元素。

但是,如果我將此擴展到:

Dim objMail As Outlook.MailItem
Dim sFrag As String   
Dim oOlApp As Outlook.Application
Dim targetFolder As folder

Set objMail = Application.ActiveExplorer.Selection.Item(i_item)
Set oOlApp = Outlook.Application
Set objNmSpc = oOlApp.GetNamespace("MAPI")
Set targetFolder = objNmSpc.PickFolder
objMail.Move targetFolder
sFrag = "<a href='outlook:" + objMail.EntryID + "'>"  + objMail.Subject + "</a>" 

之后, sfrag中的鏈接sfrag失敗。 如果要打開此鏈接,則Outlook窗口將顯示Operation failed 似乎objMail.EntryID是不正確后,更新objMail.Move命令。

為什么? 如何解決這個問題?

Move是一個函數,而不是一個子函數-它重新運行新項:

set objMail = objMail.Move(targetFolder)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM