Solved

press button reply to email with attachment

Posted on 2013-06-22
7
368 Views
Last Modified: 2013-06-24
I receive a lot of emails to which I need to provide a common textual reply with an attachment. At the moment I am inserting a customised signature, deleting the two unwanted blank lines it installs at the top and then manually attaching the file I need to send. I would prefer to have a button or some other easy to implement trigger that simply does it for me with the currently selected email. Is there any way I can do this? I am using Outlook 2007
0
Comment
Question by:Rob4077
  • 4
  • 3
7 Comments
 

Author Comment

by:Rob4077
ID: 39268001
Just to clarify, the text I need to insert in the selected emails is something like:
     "Thank you for your email. .... As requested, attached is a copy of the latest report. ..."

I then attach the report. I would like a VBA module or something that will enable me to do this at the push of a button
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39270783
Hi, Rob4077.

This should do it.  Follow these instructions to add the macro to Outlook.

1.  Start Outlook
2.  Press ALT+F11 to open the Visual Basic editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor

Sub ReplyWithAttachment()
    'On the next line edit the text you want to insert into the reply
    Const REPLY_TEXT = "The text of your reply."
    'On the next line edit the path to and name of the file you want to attach to your reply
    Const ATTACH_PATH = "C:\Test.txt"
    Dim olkMsg As Outlook.MailItem, olkRpl As Outlook.MailItem
    Set olkMsg = Application.ActiveExplorer.Selection(1)
    Set olkRpl = olkMsg.Reply
    With olkRpl
        Select Case olkRpl.BodyFormat
            Case olFormatHTML
                olkRpl.HTMLBody = REPLY_TEXT & olkRpl.HTMLBody
            Case Else
                olkRpl.Body = REPLY_TEXT & olkRpl.Body
        End Select
        olkRpl.Attachments.Add ATTACH_PATH
        olkRpl.Send
    End With
    Set olkMsg = Nothing
    Set olkRpl = Nothing
End Sub

Open in new window

0
 

Author Comment

by:Rob4077
ID: 39271420
That worked perfectly. Thank you!!! You've got full points

Since it worked so well, is it too much to ask for two changes (assuming it's not a mass of extra work).

1. Is it difficult to move the email to a subfolder of the Inbox called DeleteIn1Month?

2. Is there any way of preventing Outlook from adding the standard email signature on the reply?

If either is too difficult or involves a lot of extra coding just let me know and I will happily work with what you have done for me already
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39271521
You're welcome.

Moving the message is no problem.  I'm assuming you want to  move the original message and not the reply you just sent.  Assuming so, then this version adds that capability.

Sub ReplyWithAttachment()
    'On the next line edit the text you want to insert into the reply
    Const REPLY_TEXT = "The text of your reply."
    'On the next line edit the path to and name of the file you want to attach to your reply
    Const ATTACH_PATH = "C:\Test.txt"
    Dim olkMsg As Outlook.MailItem, olkRpl As Outlook.MailItem
    Set olkMsg = Application.ActiveExplorer.Selection(1)
    Set olkRpl = olkMsg.Reply
    With olkRpl
        Select Case olkRpl.BodyFormat
            Case olFormatHTML
                olkRpl.HTMLBody = REPLY_TEXT & olkRpl.HTMLBody
            Case Else
                olkRpl.Body = REPLY_TEXT & olkRpl.Body
        End Select
        olkRpl.Attachments.Add ATTACH_PATH
        olkRpl.Send
        olkMsg.Move Session.GetDefaultFolder(olFolderInbox).Folders("DeleteIn1Month")
    End With
    Set olkMsg = Nothing
    Set olkRpl = Nothing
End Sub

Open in new window

     

I don't know of a way to prevent Outlook from adding the standard signature  to the reply.
0
 

Author Comment

by:Rob4077
ID: 39271567
Thank you very, very much. This will save me hours of work every month. Really appreciate it!!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39271631
You're welcome.  I'm happy I could help out.
0
 

Author Comment

by:Rob4077
ID: 39271687
I'm very happy you did help so much
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question