# Outlook 2007 'reply to all' in a macro.

**URL:** <https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794>\
**Category:** Factual Questions\
**Created:** [January 28, 2010, 6:51pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794 "2010-01-28T18:51:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [January 28, 2010, 6:51pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/1 "2010-01-28T18:51:11Z")

</div>

A member of the dope very kindly gave me the following code to reply to a plain-text email in html. Unfortunately I forget who it was. But I’ve already thanked them 🙂

Anyway. This code does a ‘reply’ email. In other words it replies to the first person in the ‘from’ field.

```auto

Option Explicit
Public Sub ReplyToPlainTextWithHTML()
   Dim HTMLReplyMail As Outlook.MailItem
 
   If Application.ActiveExplorer.Selection.Count Then
 
      If TypeOf Application.ActiveExplorer.Selection(1) Is Outlook.MailItem Then
 
         Set HTMLReplyMail = Application.CreateItem(olMailItem)
 
         HTMLReplyMail.To = Application.ActiveExplorer.Selection(1).SenderEmailAddress
         HTMLReplyMail.BodyFormat = olFormatHTML
         HTMLReplyMail.Subject = "Re: " & Application.ActiveExplorer.Selection(1).Subject
 
         Dim SigString As String
         SigString = "C:\Documents and Settings\" & Environ("username") & _
                                     "\Application Data\Microsoft\Signatures\compact.htm"
         Dim mailSig As String
         If Dir(SigString) <> "" Then
            mailSig = GetBoiler(SigString)
         Else
            mailSig = ""
         End If
          HTMLReplyMail.HTMLBody = "<br><br>" & mailSig & "<br>" & _
                                 "-----Original Message-----" & "<br>" & _
                                 "From: " & Application.ActiveExplorer.Selection(1).SenderName & "<br>" & _
                                 "Sent: " & Application.ActiveExplorer.Selection(1).SentOn & "<br>" & _
                                 "To: " & Application.ActiveExplorer.Selection(1).To & "<br>" & _
                                 "cc: " & Application.ActiveExplorer.Selection(1).CC & "<br>" & _
                                 "Subject: " & Application.ActiveExplorer.Selection(1).Subject & "<br>" & _
                                  Application.ActiveExplorer.Selection(1).HTMLBody
 
        HTMLReplyMail.Display
 
      End If
 
   End If
End Sub
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function

```

So my question is, how would I go about changing this code so that it does ‘reply to all’ instead of just ‘reply’?

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [January 30, 2010, 4:50pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/2 "2010-01-30T16:50:40Z")

</div>

I’ll give this one bump.

---

<div class="post-metadata">

**Author:** ![Rhythmdvl](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rhythmdvl](https://boards.straightdope.com/u/Rhythmdvl)\
**Post date:** [January 30, 2010, 5:05pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/3 "2010-01-30T17:05:11Z")

</div>

Sorry to not have an answer, but since you already seem a bit more advanced than I, do you know how to bind a key to a macro?

---

<div class="post-metadata">

**Author:** ![Ruminator](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@Ruminator](https://boards.straightdope.com/u/Ruminator)\
**Post date:** [January 30, 2010, 5:06pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/4 "2010-01-30T17:06:26Z")

</div>

> [@Lobsang](#):
>
> So my question is, how would I go about changing this code so that it does ‘reply to all’ instead of just ‘reply’?

Looking at [MSDN documentation](http://msdn.microsoft.com/en-us/library/bb175516.aspx) for custom coding MS Outlook…

It looks like you’d have to iterate through all the names in the “**[To](http://msdn.microsoft.com/en-us/library/bb206711.aspx)**” and “**[Cc](http://msdn.microsoft.com/en-us/library/bb207136.aspx)**” properties and build (.Add) all the names in the “Recipients” collection property.

It’s more than just a minor tweak to a single line of code.

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [January 30, 2010, 5:25pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/5 "2010-01-30T17:25:42Z")

</div>

> [@Rhythmdvl](#):
>
> Sorry to not have an answer, but since you already seem a bit more advanced than I, do you know how to bind a key to a macro?

I have the macro set as a button on my toolbar..

Right click on the toolbar and click ‘customize’

then right click on the button you want to assign a key to. In the name, add an ampersand before one of the letters in the name. That letter becomes the shortcut key.

You need to pick a letter that isn’t already used by something else.

Mine is called ‘repy html’ so I put the ampersand before the ‘m’ and I hold alt-m to get the macro to run,

EDIT: There might be better ways to assign shortcut keys to tasks/macros in outlook, but the one above is the one I was able to figure out just now 🙂

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [January 30, 2010, 5:32pm UTC](https://boards.straightdope.com/t/outlook-2007-reply-to-all-in-a-macro/526794/6 "2010-01-30T17:32:40Z")

</div>

> [@Ruminator](#):
>
> Looking at [MSDN documentation](http://msdn.microsoft.com/en-us/library/bb175516.aspx) for custom coding MS Outlook…
> 
> It looks like you’d have to iterate through all the names in the “**[To](http://msdn.microsoft.com/en-us/library/bb206711.aspx)**” and “**[Cc](http://msdn.microsoft.com/en-us/library/bb207136.aspx)**” properties and build (.Add) all the names in the “Recipients” collection property.
> 
> It’s more than just a minor tweak to a single line of code.

Thanks. It looks like I could get there if I spend some time on it.
