Auto-reply confirmation email



I am looking for some help with setting up the following rule:

when mail is received in inbox from "(e-mail address removed)" with the subject
"Email Subject," do the following:

-sends reply to the "reply-to" address not the "from" address
-includes original message text in body of reply

I have no problem setting up the rule to pull the from and subject lines,
also I have set it to run a script, however I think I am having difficulties
pulling the reply address.

This is what I have come up with so far. Also, I am putting this code in

Sub AutoReply(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim rply As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)

Set rply = msg.Reply

rply.Body = msg.Body
rply.Subject = msg.Subject
rply.To = msg.ReplyRecipients.Item(1).Address

Set msg = Nothing
Set rply = Nothing
Set olNS = Nothing

End Sub

If you couldn't tell, this is my first time doing any script programming for
Outlook, so I am sure I am just missing something obvious.


Sue Mosher [MVP-Outlook]

You're doing extra work that's not necessary. The message returned by
msg.Reply is already using the reply-to address, not the from address.


Sue, thanks.
I commented out this line:

rply.To = msg.ReplyRecipients.Item(1).Address

and gave it a try...

Original message comes into the inbox but no reply email is being sent out
when the rule is turned on and run.

if I right-click the message and look at the properties, the correct email
address is in the "reply-to" field.

Anything else you see that I need to be doing differently?


Sue Mosher [MVP-Outlook]

What can you learn from looking at the contents of rply.Recipients?

What happens when you run this procedure from a macro, passing it a received
message as an argument?
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question