-
Solved: Standard ReplyAll with an attachment
I'm an Outlook 2003 VBA newbie trying to write a macro that will ReplyAll to the current (Inspector) email, add an attachment (C:Form.doc), and add text ("Please complete the attached form and return to sender.") to the top of the Body.
I have made several attempts, but each results in various errors (e.g. standard Reply format is altered (as set by: Outlook / Tools / Options / Preferences / E-mail Options / On Replies and Forwards / Include original message text).
Does anyone have a ReplyAll macro (that includes an .Add attachment) that I can use as a reference? Thanks, signed Newbie
Last edited by wagnet; 01-17-2006 at 03:49 PM.
-
I finally got it to work. Let me know if you see any code improvements that can be made. Thanks.
[VBA] Sub Reply2AllSCQ()
' 2006 January 17 AAW - Written
' ReplyAll to open email requesting sender complete and return the attached SQC file
Dim objOutlook As Outlook.Application
Dim atts As Outlook.Attachments
Dim newAttachement As Outlook.Attachments
Dim objMail As Outlook.MailItem
Dim objItem As Object
Dim strAddress As String
Dim strName As String
Dim strEntryID As String
Dim strMessage As String
strMessage = "Please complete and return the attached SCQ Form." & vbCrLf & vbCrLf & "Thank You."
Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.ActiveInspector.CurrentItem
Set objMail = objItem.ReplyAll
CopyBody = objMail.Body
objMail.Body = vbCrLf & strMessage & vbCrLf & vbCrLf & CopyBody
Set newAttachments = objMail.Attachments
newAttachments.Add "C:SCQ.doc", _
olByValue, 1, "SCQ Questionnaire"
objMail.Display
End Sub[/VBA]
-
Hi Wagnet,
Welcome to VBAX.
I'm sure some Outlook knowlegeable person will be along soon. When you post code, if you select it and click the VBA burtton, it will format your code making it more readable. Please also use linebreaks in long lines of code, to avoid the need for scrolling.
Regards MD
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules