In Outlook (2016 or 365), I would like to use VBA to create a rule that moves items I send to a specific person.
I've got most of the code done (lifted from a Microsoft code sample), but I can't figure out what the condition fields should get. I know it isn't right (there's no such thing as ".sender" in that type of object), but I don't know what I SHOULD put there. There are only seven properties on a ToOrFromRuleCondition (Application, Class, ConditionType, Enabled, Parent, Recipients, and Session), and none of them deal with the sender.
In the code below:
- colRules, objRuleSend are Outlook.Rules objects
- objToCondition is an Outlook.ToOrFromRuleCondition
- RuleName is a string with only letters in it
- Address is a string variable with a name.name@company.com format.
Set colRules = Application.Session.DefaultStore.GetRules()
Set objRuleSend = colRules.Create(RuleName & "Send", olRuleSend)
Set objToCondition = objRuleSend.Conditions.SentTo
With objToCondition
.Enabled = True
.Sender = Address ' <-- this is the line that fails.
.Recipients.ResolveAll
End With