PDA

View Full Version : Macro to reply to all with specific text



hbelal
11-19-2018, 06:23 AM
I am looking for outlook macro which will enable me to reply to all with specific text. I need later to link this macro to icon in the quick access toolbar.

gmayor
11-19-2018, 07:44 AM
The following should work


Sub ReplyToAllWithText()
'Graham Mayor - https://www.gmayor.com - Last updated - 19 Nov 2018
Dim olMsg As MailItem
Dim olReply As MailItem
Dim olInsp As Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim strTo As String

On Error GoTo Err_Handler
Set olMsg = ActiveExplorer.Selection.Item(1)
Set olReply = olMsg.ReplyAll
With olReply
.BodyFormat = olFormatHTML
.Display
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse 1
oRng.Text = "This is a line of text." & vbCr & _
"This is another line" & vbCr & _
"This line will be followed by your account signature."
End With
lbl_Exit:
Set olMsg = Nothing
Set olReply = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
Exit Sub
Err_Handler:
Beep
Err.Clear
GoTo lbl_Exit
End Sub

hbelal
11-19-2018, 10:07 PM
The following should work



Thanks Gmayor for the help. Code is perfect. But it is not sending the reply, I mean code is making message ready as I want but is it possible to amend the code to send the email as well so I don't have to press on SEND by myself?

gmayor
11-20-2018, 07:53 AM
If you are happy it works as you require, add the line
.sendimmediately before the line
End WithDo not remove the
.Displayline or the message body will not be written.

hbelal
11-20-2018, 09:58 PM
If you are happy it works as you require, add the line

Thanks one more time for the support. It works perfectly.