0

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
0

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
| improve this answer | |
  • Ah, so move is copy and delete behind the scenes. Got it. Works perfectly. (Added olItem.UnRead = False after the move line). Too bad I couldn't just get a QuickStep to do this and I had to use a macro... – Scott Apr 22 '16 at 12:14
  • There is also an Outlook option that might help. File > Options > Mail > Save messages > When replying to a message that is not in the Inbox, save the reply in the same folder. That, combined with a Move and Reply Quick Step might work too. – IMTheNachoMan Apr 22 '16 at 15:55
  • I have that activities. Problem is with the quickstep, the move works, but the reply is saved in inbox (same problem as here - have to reply to the new object) – Scott Apr 23 '16 at 16:49
  • Did you change that Outlook setting? – IMTheNachoMan Apr 23 '16 at 17:22
  • Yes, it is activated since day 1. This just is a big hole for MS not to offer a file and send that works out of the box. AFAIK, nearly every business person will want this function. – Scott Apr 25 '16 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.