Solved

press button reply to email with attachment

Posted on 2013-06-22
7
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Outlook Free & Paid Tools
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

756 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