I am trying to add a "from account" condition to a set of Outlook Rules, which are created by VBA. The DisplayName of the account is: abcd@abcd.com, AccountType is: 0 and Class is: 105.
Dim oAccountRuleConditionSubscribe As Outlook.AccountRuleCondition
Dim oRuleNew As Outlook.Rule
Set oAccountRuleConditionSubscribe = oRuleNew.Conditions.Account
With oAccountRuleConditionSubscribe
.Enabled = True
.Account.DisplayName = abcd@abcd.com
End With
The above is the latest I could come up with, and still it will not take abcd@abcd.com as a valid account reference. I have exhausted all tutorials, glossaries and MSDN resources, and I would really appreciate your help.
I found a workaround, thanks to Eugene, with:
Dim oAccountRuleConditionSubscribe As Outlook.AccountRuleCondition
Dim oRuleNew As Outlook.Rule
Dim OutApp As Outlook.Application
Set OutApp = CreateObject("Outlook.Application")
Set oAccountRuleConditionSubscribe = oRuleNew.Conditions.Account
With oAccountRuleConditionSubscribe
.Enabled = True
.Account = OutApp.Session.Accounts.item(2)
End With
But I am still struggling ot identigy the account by its DisplayName.
Any pointers?