• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help with Outlook VBA - Need to catch Subject and sender and return an answer with a template.

Kenny Outzen

New Member
Hi,

I am looking for help.

I am currently trying to set up 8 different macros, where i reply to different types of e-mails using standard templates.

So far i have gotten this piece of code to work.

"
Sub Reply_Scripting()
'Open Confirmation email template.
Dim origEmail As MailItem
Dim replyEmail As MailItem
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("Y:\Templates\Thank you for your order.oft")
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.reply.HTMLBody
replyEmail.Display
End Sub
"

What i am missing, is:
  1. how can i get the e-mail to include the original sender of the e-mail as the new recipient
(if i get the e-mail from xxx@xxx.com i want the macro to reply to xxx@xxx.com

  1. how to i reuse the subject from the original e-mail? (ie. if i get an e-mail with subject XXX - i want my macro to get the old subject, and return Re: XXX)

Hope anyone can help.

Regards,
Kenny
 
1. Try using "Sender" Property of origEmail (i.e. origEmail.Sender)
Then make "To" property of replyEmail equal to above.

2. Similar to above, use "Subject" property.
But concatenate with "RE:".
 
Back
Top