【发布时间】:2016-05-15 13:49:35
【问题描述】:
我想将邮件项移动到不同的文件夹,然后返回指向移动邮件的链接。不移动它的工作原理是:
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 中的链接失败。如果我想打开这个链接,Outlook-windows 会显示Operation failed。似乎objMail.EntryID 在objMail.Move 命令之后没有正确更新。
为什么?如何解决这个问题?
【问题讨论】:
标签: vba email hyperlink outlook move