I have a VBA script that moves an email to a folder (dialog box) and generates a reply that will be saved in the same folder. The problem I am having is the original email never shows the reply icon with purple arrow. Any ideas what I am missing?
Sub FileAndReply()
'This subroutine will move the highlighted email to a user selected folder
'and generate a reply that will be saved in the same folder.
'PROBABLY: Must have Save copy of messages in Sent folder set.
'MAYBE: Must have When replying to a message that is not in the Inbox, save...
Dim olApp As New Outlook.Application
Dim olExp As Outlook.Explorer
Dim olSel As Outlook.Selection
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.Folder
Dim olItem As Outlook.MailItem
Set olExp = olApp.ActiveExplorer
Set olSel = olExp.Selection
Set olNS = olApp.GetNamespace("MAPI")
'get folder user wants to put email in
Set olFolder = olNS.PickFolder
If TypeName(olFolder) <> "Nothing" Then
olSel.Item(1).Move olFolder
Set olItem = olSel.Item(1).Reply
'TO BE FIXED: reply object is created, but original message does
'not get the icon showing replied to purple arrow!
Set olItem.SaveSentMessageFolder = olFolder
olItem.Display
Else
MsgBox ("No folder selected. Script aborted.")
End If
End Sub
Answer
When you move an item a new item is created. You need to do the reply on the new item.
Sub FileAndReply()
'This subroutine will move the highlighted email to a user selected folder
'and generate a reply that will be saved in the same folder.
'PROBABLY: Must have Save copy of messages in Sent folder set.
'MAYBE: Must have When replying to a message that is not in the Inbox, save...
Dim olApp As New Outlook.Application
Dim olExp As Outlook.Explorer
Dim olSel As Outlook.Selection
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.folder
Dim olItem As Outlook.MailItem
Set olExp = olApp.ActiveExplorer
Set olSel = olExp.Selection
Set olItem = olSel.Item(1)
Set olNS = olApp.GetNamespace("MAPI")
'get folder user wants to put email in
Set olFolder = olNS.PickFolder
If TypeName(olFolder) <> "Nothing" Then
Set olItem = olItem.Move(olFolder)
Set olItem = olItem.Reply
'TO BE FIXED: reply object is created, but original message does
'not get the icon showing replied to purple arrow!
Set olItem.SaveSentMessageFolder = olFolder
olItem.Display
Else
MsgBox ("No folder selected. Script aborted.")
End If
End Sub
No comments:
Post a Comment