Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook Reply or ReplyAll to an Email

Tags:

email

vba

outlook

Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.To = "[email protected]"
objMail.cc = "[email protected]"
objMail.Subject = "Mail test"
objMail.HTMLBody = "This is my message"
unload me
objMail.Display
Set objMail = Nothing
Set objOutlook = Nothing

I am trying to add in another function that help to reply a selected email but can't figure out how I can mix this with Item As Outlook.MailItem I understand that replying an email will require that.

So I would like to know how I can add on so that I can select an email, execute the macro and it will input the recipient email into objMail.To and recipient's body into objMail.HTMLBody

like image 723
Zheng Yi Chew Avatar asked Aug 04 '15 19:08

Zheng Yi Chew


People also ask

Should I reply or reply to all in email?

Use Reply when you only want to send your message to a single person in an email thread -- either the original sender of the email or the last person to reply in the thread. Reply All when you want to respond to every contact on the thread.

Why You Should not Use Reply All?

When you use reply all, there's a chance you're including people who no longer need to be included in the email chain, wasting their time with each new email. Sometimes someone on the chain has a side thought about the conversation.

Does reply all include the sender?

It should only include yourself in the reply to all if the address the message was sent to is not the same as the account address. If your From address is the same as the address the message was sent to, Outlook can properly identify your address and will not include it in a 'reply to all'.


1 Answers

To simply Reply or ReplyAll selected messages try the following.

Option Explicit
Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem ' Reply
    Dim olRecip As Recipient ' Add Recipient
    
    For Each olItem In Application.ActiveExplorer.Selection
        Set olReply = olItem.ReplyAll
        Set olRecip = olReply.Recipients.Add("Email Address Here") ' Recipient Address
        olRecip.Type = olCC
        olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
        olReply.Display
    
        'olReply.Send
    Next olItem
End Sub

To hide the recipient use BCC Example

olRecip.Type = olBcc

To add multiple recipient just add

Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")

With out Recipient try the following.

Option Explicit
Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem ' Reply

    For Each olItem In Application.ActiveExplorer.Selection
        Set olReply = olItem.ReplyAll
        olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
        olReply.Display

        'olReply.Send
    Next olItem
End Sub
like image 96
0m3r Avatar answered Oct 04 '22 19:10

0m3r