[RESOLVED] [Outlook] Selected Message Item
The purpose of the code is to create a copy of the selected message as a task form.
The problem: I don't now how to use the selected message property. At the moment I copy the body of a specified message item (Item (2) in the example below) and not the message selected by the user at the time.
This code is run from a custom button on the toolbar of the main outlook explorer window and the opened message window.
My code:
Code:
Sub DisplayForm()
Set myMailFolder = Session.GetDefaultFolder(olFolderInbox)
Set myMailItem = myMailFolder.Items(2)
Set myTaskFolder = Session.GetDefaultFolder(olFolderTasks)
Set myItem = myTaskFolder.Items.Add("IPM.Task")
With myItem
.Subject = myMailItem.Subject
.Body = myMailItem.Body
End With
myItem.Display
End Sub
Ps. Our exchange mail server is 3rd pary software and does not support custom forms. The custom actions on the design forms function does therefore not work. I have to do it in vbscript.
Thanks.
Re: [Outlook] Selected Message Item
I hae managed to resolve the issue. For the benefit of others that might search this thread in trouble shooting, I've posted the code below:
Code:
Set myTaskFolder = Session.GetDefaultFolder(olFolderTasks)
Set myOlSel = Application.ActiveExplorer.Selection
For x = 1 To myOlSel.Count
Set myparentitem = myOlSel.Item(x)
NewTask myparentitem
Next x
NewTask is a subroutine that creates a task with the the same subject and body as the "parent item", which is a mailitem in this case.