'MS OFFICE VBA EQUIVALENT (ONLY MS OFFICE 2007)
'create Folder
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders.Item(1)
Set myNewFolder = myFolders.Folders.Add("FolderAddedFromVBA")
'create rule
Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim colRuleActions As Outlook.RuleActions
Dim oMoveRuleAction As Outlook.MoveOrCopyRuleAction
Dim oFromCondition As Outlook.AddressRuleCondition
Dim oInbox As Outlook.Folder
Dim oMoveTarget As Outlook.Folder
Set oMoveTarget = myFolders.Folders("FolderAddedFromVBA")
Set colRules = myOlApp.Session.DefaultStore.GetRules()
Set oRule = colRules.Create("FolderAddedFromVBA", olRuleReceive)
Set oFromCondition = oRule.Conditions.SenderAddress
With oFromCondition
.Enabled = True
.Address = Array("fromvba.org.by")
End With
Set oMoveRuleAction = oRule.Actions.MoveToFolder
With oMoveRuleAction
.Enabled = True
.Folder = oMoveTarget
End With
colRules.Save