Auto-reply confirmation email

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

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
ThisOutlookSession

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
rply.Send

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.

Thanks!
 
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?

Thanks!
 
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
http://www.outlookcode.com/article.aspx?id=54
 
Back
Top