Setting ExpiryTime and Unread State for MailItem

  • Thread starter Thread starter Peter Crickman
  • Start date Start date
P

Peter Crickman

I am trying to write a Outlook script in VBA to execute using the "Run a
Script" option in the Rules Wizard under Outlook 2002. The macro appears to
execute properly but does not save the updated mail item in the Inbox. Do I
need some additional permissions to save updated items to my Inbox? Are
these properties not updatable?

Sub ExpireMail(MyMail As MailItem)
MyMail.ExpiryTime = DateAdd("m", 1, Date)
MyMail.UnRead = True
MyMail.Save
End Sub


Thanks for any help,
Peter
 
Further testing confirms that this rule executes fine and the updates are
saved as expected. There is a second rule that fires that is supposed to
move the mail item to a .pst folder. It is located in the Rule list after
the update rule. When both rules are executed together using the Run Now...
option, the original mail item gets moved to the .pst folder, not the
updated one. I would like the rules to execute in combination. What would
explain this behavior?


I am trying to write a Outlook script in VBA to execute using the "Run a
Script" option in the Rules Wizard under Outlook 2002. The macro appears to
execute properly but does not save the updated mail item in the Inbox. Do I
need some additional permissions to save updated items to my Inbox? Are
these properties not updatable?

Sub ExpireMail(MyMail As MailItem)
MyMail.ExpiryTime = DateAdd("m", 1, Date)
MyMail.UnRead = True
MyMail.Save
End Sub


Thanks for any help,
Peter
 
When I join the two rules as one the first action specified is to move the
mail item to the .pst folder and then run the script. I thought that the
script is only able to execute on Inbox items?? There does not appear any
way to order the actions so that the script executes first. Can the script
perform the move command itself? What is the syntax for the move command?

Peter


Hi Peter,

you should join the both rules to only one.
 
Yes, it can and the move command is called... Move! Just type it in and
press F1 for a sample.
 
Back
Top