0

I have macro to forward an email with the original attachment to everyone which is involved in the original email chain.

    Sub my_test()

Dim objItem As Object

Dim mail As MailItem
Dim forwardMail As MailItem

Dim templateItem As MailItem

For Each objItem In ActiveExplorer.Selection

    If objItem.Class = olMail Then
    
        Set mail = objItem
        Set forwardMail = mail.Forward
        
        Set templateItem = CreateItemFromTemplate("C:\template.oft")
        
        With forwardMail
            .HTMLBody = templateItem.HTMLBody & .HTMLBody
            .To = mail.replyall.To & mail.replyall.CC
            .Display
        End With
        
    End If
    
Next

End Sub

Is it possible to mark this email has "replied" instead of "forwarded" email?

H.N.
  • 1,207
  • 2
  • 12
  • 28

2 Answers2

0

yes you need only to change Set forwardMail = mail.Forward to Set forwardMail = mail.Reply

You should also change name of variable forwardMail to replyMail and change all variables in code. full code below.

Sub my_test()

Dim objItem As Object
Dim mail As MailItem
Dim replyMail As MailItem
Dim templateItem As MailItem

For Each objItem In ActiveExplorer.Selection

If objItem.Class = olMail Then

    Set mail = objItem
    Set replyMail = mail.Reply
    
    Set templateItem = CreateItemFromTemplate("C:\template.oft")
    
    With replyMail
        .HTMLBody = templateItem.HTMLBody & .HTMLBody
        .To = mail.replyall.To & mail.replyall.CC
        .Display
    End With
    
 End If

Next

End Sub
Tomasz
  • 426
  • 2
  • 10
  • Yes, but he 'forgot' telling us that the forwarded mail has an attachment, which will be lost without some tricks (saving the attachments and reattach them when replying) I supplied such an answer to his first question but he did not like it. It happens I could see his first question where he received such an answer, but in different circumstances. It is not your fault, but I am afraid that he will not be happy with the answer... – FaneDuru Feb 11 '21 at 20:19
  • loop which make object variable from each attachment from received mail and next loop which use method attachment.add object in replied mail will not work? – Tomasz Feb 11 '21 at 20:25
  • Yes. I posted such a code. Only to make Outlook mark the mail as replied. Otherwise, it is simpler to use Forward and only use `mail.replyall.To & mail.replyall.CC`. But the mail is not ticked as replied... – FaneDuru Feb 11 '21 at 20:31
  • yes its simpler, only one line. i checked and its imposible to add attachment as object variable. i think it's necessary to save all attachment in temporary location od hd the make string array with path, thenn use loop to attachment.add from path and next delete all temporary files. as you wrote not simple :) – Tomasz Feb 11 '21 at 20:39
0

If you mean you want to change the icon to the one that represents "replied", you can change it in the following way...

' Set property PR_ICON_INDEX to 261
objItem.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x10800003", 261
objItem.Save
Sam
  • 361
  • 1
  • 5
  • 8