Consulting

Results 1 to 5 of 5

Thread: Macro to reply to all with specific text

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Posts
    14
    Location

    Wink Macro to reply to all with specific text

    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.

  2. #2
    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular
    Joined
    Nov 2018
    Posts
    14
    Location
    Quote Originally Posted by gmayor View Post
    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?

  4. #4
    If you are happy it works as you require, add the line
    .send
    immediately before the line
    End With
    Do not remove the
    .Display
    line or the message body will not be written.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5
    VBAX Regular
    Joined
    Nov 2018
    Posts
    14
    Location
    Quote Originally Posted by gmayor View Post
    If you are happy it works as you require, add the line
    Thanks one more time for the support. It works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •