Outlook VBA link 已移动邮件
Outlook VBA link to moved mail
我想将邮件项目移动到不同的文件夹,然后 return 将 link 移动到移动的邮件。在不移动的情况下,它的工作方式为:
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
提供正确的 hyperlink 到有效的 Outlook 元素。如果我单击包含此 属性 的 hyperlink,该元素将在 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
中的 link 失败。如果我想打开这个 link,Outlook-windows 显示 Operation failed
。似乎 objMail.EntryID
在 objMail.Move
命令后没有正确更新。
为什么?如何解决这个问题?
Move 是一个函数,而不是子函数 - 它返回新项目:
set objMail = objMail.Move(targetFolder)
我想将邮件项目移动到不同的文件夹,然后 return 将 link 移动到移动的邮件。在不移动的情况下,它的工作方式为:
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
提供正确的 hyperlink 到有效的 Outlook 元素。如果我单击包含此 属性 的 hyperlink,该元素将在 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
中的 link 失败。如果我想打开这个 link,Outlook-windows 显示 Operation failed
。似乎 objMail.EntryID
在 objMail.Move
命令后没有正确更新。
为什么?如何解决这个问题?
Move 是一个函数,而不是子函数 - 它返回新项目:
set objMail = objMail.Move(targetFolder)