In-line reply style in Outlook
I've been forced to use MS Outlook as a mail client for some years now. For my work, I tend to communicate with Open Source software developers and mailinglists quite often. Needless to say, the Outlook reply style and HTML formatting of messages is not really compatible with that.
To overcome this, I've been using a VBA macro to create a special ReplyToAll button. Today, I've perfected this macro and I'm publishing it for others to use.
The macro has the following features:
- Reply in Plain Text automatically
- Set Reply Style to use '>' indenting, a.k.a. in-line reply style
- Get rid of automatic signature that Outlook may insert into the reply
- Remove the Outlook Reply header and replace with "On <DATE>, <NAME> wrote:"
Note that I'm not at all experienced in writing VBA macros, so the coding is a bit messy:
' ' Reply To All in Plain Text, with Linux-style quoting ' ' This allows you to use Outlook to reply to a mailinglist ' ' Copyright 2009 Matthijs van de Water ' Sub ReplyAllPlain() Dim app As New Outlook.Application Dim exp As Outlook.Explorer Set exp = app.ActiveExplorer Dim strID As String Dim olNS As Outlook.NameSpace Dim item As Outlook.MailItem 'Get MailItem based on EntryID, otherwise we'll get security warnings strID = exp.Selection.item(1).EntryID Set olNS = Application.GetNamespace("MAPI") Set item = olNS.GetItemFromID(strID) ' Store name of the sender and date of sent message Dim name As String name = item.SentOnBehalfOfName datestr = Format(item.SentOn, "DDD, MMM dd, yyyy at HH:mm:ss") ' ReplyToAll to this message in Plain formatting with > style item.BodyFormat = olFormatPlain item.Actions("Reply to All").ReplyStyle = olReplyTickOriginalText Dim rply As Outlook.MailItem Set rply = item.ReplyAll ' Rebuild original body: ' - Remove Outlook-style reply header ' - Get rid of auto-inserted signature (optionally move to end of message) orgBody = rply.Body pos = InStr(orgBody, ">") - 1 sig = Left(orgBody, pos) myBody = Mid(orgBody, pos + 1) b = 0 lines = Split(myBody, vbNewLine) For Each myLine In lines If b > 4 Then newBody = newBody & myLine & vbNewLine End If b = b + 1 Next ' Put new body together rply.Body = "On " & datestr & ", " & name & " wrote:" _ & vbNewLine & newBody & vbNewLine '& sig rply.Display item.Close olDiscard End Sub
Nice work on the VB macro, however there is an easier solution if you are using Office 2007 (haven't tested on 2003).
Go to Tools / Options
In the Preferences tab select E-mail Options... at the top.
In the On replies and forwards section at the bottom for each of the two drop downs select Prefix each line of the original message
Then at the second input box from the bottom, put in the reply style you want to use.
Great tutorial by the way, I am on running Outlook on Crossover Office and macros don't like it haha.
What you're referring to will set the reply style for all outgoing messages.
This macro will set it only for the message you're using it on.
Thanks for your feedback anyway
This does not work when you reply to HTML/RTF messages.
Thanks for your macro; it's very useful.
However, I'd like to suggest a modification to the part where the actual header is skipped. The current method is to skip the first 5 lines. But mail header some times contain CC, Importance fields etc., which will make the header more than 5 lines. This will in turn result in extra (and unwanted) lines in the body created by the macro. So the alternative method to screen the header could be to filter from "-----Original" to an empty line, or to skip lines matching pattern "^> [a-zA-z]+: "
VBA is alien to me, and couldn't write this logic error free
I had a similar problem: some emails, especially long CC lists and titles, end up with a header that takes more than the allowed 4 lines.
For Each myLine In Lines
If b Then
newBody = newBody & myLine & vbNewLine
If myLine = "> " Then
b = True
This skips the first empty line as well. Change the order of the two "If" statements to keep it.
Extremely useful macro. Thanks a lot!
I am new to Outlook world (spent all my life with Linux). Can you tell how to apply (install) this script? Or any reference to documentation?
this is the code I've been searching for!
I've been jealous of the stream-lined gmail replies for years now, and have been frustrated by the lack of ability to re-template the replies in Outlook. I've remixed your code into a general purpose macro that is able to perform the same action across all body types.
Thanks for the head start!