Why can't I reply to email with a rule and a custom action script?

H

hogwell

Help!

I am trying to write a custom action for a client-side rule in Outlook
2007.

When an incoming email arrives with certain text in the subject, I
want to send a canned Reply email to the SenderName given by the
incoming email, which will be a valid email address.

This code works, and it pops up a msgbox with the SenderName shown
(note the commented-out code):

Sub CustomMailMessageRule(MyMail As Outlook.MailItem)

On Error GoTo AnError

MsgBox "Mail message arrived from: " & MyMail.SenderName

'Dim objReplyMail As Outlook.MailItem
'Set objReplyMail = Application.CreateItem(olMailItem)
'objReplyMail.Recipients.Add "(e-mail address removed)"
'MyMail.SenderName
'objReplyMail.SenderEmailAddress = "(e-mail address removed)"
'objReplyMail.Body = "test: " & MyMail.SenderName
'objReplyMail.Send
'Set objReplyMail = Nothing

Exit Sub

AnError:
MsgBox Err.Description

End Sub

However, if I uncomment the code so that an email will be generated,
the action does *nothing*, not even pops up an error msgbox !!!

What am I doing wrong here?

Is there some security setting that might be silently disabling the
script when I uncomment the code?

Thanks for any advice!
 
H

hogwell

Follow up...

I was able to get this working by removing the line setting the
SenderEmailAddress.

This property is apparently a read-only property and prevented the
script from running.

I still don't understand why the On Error didn't trigger, though..
..
 

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

Top