I was checking Twitter for questions about Outlook yesterday when I came across this one from smelibari.
Outlook doesn’t retain attachments on replies, presumably because the reply is going back to the person that sent the attachment(s). Clearly they must already have them or they couldn’t have sent them to you. So, while I’m not sure what the use case is for replying with attachments, the solution is pretty simple. Use a macro to create the reply, then add all the attachments from the original message to the reply. The macro will work with both an open message or a message selected in a folder. Of course the open/selected item must be an email. This solution should work with Outlook 2007 and later.
Follow these instructions to add the code to Outlook.
- Start Outlook
- Press + to open the Visual Basic Editor
- If not already expanded, expand Microsoft Office Outlook Objects
- If not already expanded, expand Modules
- 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.
- Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
- Click the diskette icon on the toolbar to save the changes
- Close the VB Editor
Sub ReplyAllWithAttachments() Const SCRIPT_NAME = "Reply All With Attachments" Dim olkMsg As Object, olkRpl As Outlook.MailItem, olkAtt As Outlook.Attachment, strTmp As String Select Case TypeName(Application.ActiveWindow) Case "Explorer" Set olkMsg = Application.ActiveExplorer.Selection(1) Case "Inspector" Set olkMsg = Application.ActiveInspector.CurrentItem Case Else Set olkMsg = Nothing End Select If olkMsg.Class = olMail Then strTmp = Environ("TEMP") & "\" Set olkRpl = olkMsg.ReplyAll For Each olkAtt In olkMsg.Attachments If Not IsHiddenAttachment(olkAtt) Then olkAtt.SaveAsFile strTmp & olkAtt.Filename olkRpl.Attachments.Add strTmp & olkAtt.Filename Kill strTmp & olkAtt.Filename End If Next olkRpl.Display Else MsgBox "This macro only works with emails.", vbCritical + vbOKOnly, SCRIPT_NAME End If Set olkMsg = Nothing Set olkRpl = Nothing Set olkAtt = Nothing End Sub Private Function IsHiddenAttachment(olkAtt As Outlook.Attachment) As Boolean ' Purpose: Determines if an attachment is a hidden attachment. ' Written: 7/12/2012 ' Author: David Lee ' Outlook: 2007 and later Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E" Dim olkPA As Outlook.PropertyAccessor, varTemp As Variant On Error Resume Next Set olkPA = olkAtt.PropertyAccessor varTemp = olkPA.GetProperty(PR_ATTACH_CONTENT_ID) IsHiddenAttachment = (varTemp <> "") On Error GoTo 0 Set olkPA = Nothing End Function
Adding Buttons to Run the Macro with a Single Click.
If smelibari wants to run the macro with a single click, then he’ll need to add a toolbar button in Outlook 2007 or a button on the Quick Access Toolbar (QAT) for Outlook 2010. Here’s how.
- Outlook 2007. Follow these instructions to add a toolbar button that runs the macro.
- Outlook 2010. Follow these instructions to add the macro to the QAT.