I want to move an mail item to an different folder and then return a link to the moved mail. Without moving it works as:
Dim objMail As Outlook.MailItem
Dim sFrag As String
Set objMail = Application.ActiveExplorer.Selection.Item(i_item)
sFrag = "" + objMail.Subject + """
Here there string sFrag
provides on proper hyperlink to to a valid Outlook element. If I click on an hyperlink containing this property the element is opened in outlook.
However if I extend this to:
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 = "" + objMail.Subject + ""
After that the link in sfrag
fails. If I want to open this link, an Outlook-windows displays Operation failed
. Seems that objMail.EntryID
is not updated correctly after the objMail.Move
command.
Why? How to fix this?
Answer
Move is a function, not a sub - it retruns the new item:
set objMail = objMail.Move(targetFolder)
No comments:
Post a Comment