Reply with Attachments Solved!
In a support forum, we should be focusing on whether or not its possible, and if it is, how to accomplish it, not spending our energies on debating the reasoning why anyone may want/need to do this.
I understand where the original author of this post is coming from and why they may need or want to send a reply with the attachment back to the sender. In my environment, this is a very common request.
I've posted this elsewhere, so I'm going to save time by copying & pasting.
Take the following real-world scenario using identical Windows XP systems & the Office 2007 Enterprise Suite:
- Sender sends an email to Recipient that contains an attachment of a document that needs to be reviewed.
- Recipient receives the email, double clicks it to open it (assume they don't use the Reading Pane), double click the document to open it, makes edits to it, clicks saves & closes the attachment.
- Recipient closes the email the opened from the sender (remember, we opened it to read it then opened the attachment), and receives the following prompt:
"The attachments of the message "SUBJECT" have been changed. Do you want to save changes to this message?"
- Recipient clicks 'Yes', which updates the email with the modified version of the attachment, and now wants to be able to click a button that will reply to the recipient with the modified attachment.
This is what I discovered:
- Clicking 'Forward' on an email containing an attachment will result in a new email being created, with blank TO, CC & BCC fields, a 'FW' prepended to the subject, the original email body contents and the attachment.
- So, clearly Outlook is capable of passing an/the attachment/s on to a new email. I checked the form actions (Open Email > Developer > Design This Form > (Actions) tab) and found 4 actions:
- Reply
- Reply to All
- Forward
- Reply to Folder
- Comparing the aforementioned actions revealed that the 'Address form like a:' values are 'Forward', 'Reply', 'Reply to All' respectively.
- This, to me, suggests there may be a [VB(?)] function, macro or some other form or action that it refers to when performing the specified '(Action)'. These are the forms, funtions, macros, actions I'm trying to view in an attempt to modify it in such a way that will result in the creation of a new option under the 'Address form like a:' field that can be used for any new '(Action)' on the forms.
- After that it's just a matter of creating a button that a user can click to perform said action.
In 2007, when you open a Word attachment (and possibly others; I've not tested with Excel, PowerPoint etc.), edit it, click save (not save as) then close the document, the new changes are saved to a temp file in randomly named folder within:
- %userprofile%\locals~1\tempor~1\content.outlook\
One is not prompted to choose a save location unless they perform a Save As; We're dealing with users here, not IT people, who instincitvely click "Save". Following the real-world example above:
- Why would Outlook behave this way (ask you to save it back to the original email) if there's no way to Reply with the attachment directly to the sender in a single action?
- If the the Microsoft Developers were operating on the notion that one should create a new email to send the now modified attachment back to the sender, why would Outlook care to look at that file?
- In most cases you don't want to modify the original, so why ask the user if they do?
These are rhetorical questions but if you have a good answer I'll listen! I don't know why it was designed this way, but it is what it is and I'm running with it!
SOLUTION:
I offer two solutions, although the latter is from Sue Mosher and is probably better since she authored Microsoft Outlook 2007 Programming.
Use the following code snippet to accomplish this task. It works on my machine & one other (both of which are XP Pro with Outlook 2007) so give it a go!
------SNIP------
Code:
Public Sub ReplyWithAttach()
'Make declarations
Dim myOlApp As Outlook.Application
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myReplyItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Dim myReplyAttachments As Outlook.Attachments
Dim fso
Dim TempFolder As String
Set fso = CreateObject("Scripting.FileSystemObject")
TempFolder = fso.GetSpecialFolder(2)
Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
'Create variable to store files names 10 max if you need more then 10, change the value below
Dim filenames(10) As String
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
For Count = 1 To myAttachments.Count
myAttachments.Item(Count).SaveAsFile "c:\" & myAttachments.Item(Count).DisplayName
filenames(Count) = myAttachments.Item(Count).DisplayName
Next
Set myItem = myInspector.CurrentItem
Set myReplyItem = myItem.Reply
Set myReplyAttachments = myReplyItem.Attachments
For Count = 1 To myAttachments.Count
myReplyAttachments.Add "c:\" & filenames(Count), olByValue, 1, ""
myReplyItem.Display
fso.DeleteFile "c:\" & filenames(Count)
Next
End If
Else
MsgBox "The item is of the wrong type."
End If
End If
End Sub
------SNIP------
I tried substituting myItem.Reply with myItem.ReplyAll, however it didn't seem to behave correctly; in fact it didn't work at all. I'd be interesting in hearing why if anyone can figure it out.
Sue's code, and comments, can be found at
http://www.outlookcode.com/codedetail.aspx?id=1228