Rule Action Type

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Rule Action Type

Post by jstevens »

I am encountering an error when I add a rule based on "sent". All other rules are based on incoming messages and the code works until I add a rule based on "sent".

Code: Select all

  Set Store = Application.Session.Stores("myAccount@gmail.com")
  Set Rules = Store.GetRules
  
  MsgBox Rules.count    'This returns the correct number of rules including the one based on "sent".
  
  For Each RuleName In Rules   'Errors out here when I add a "sent" rule.
    Debug.Print RuleName
  Next RuleName
EL_87.png
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
HansV
Administrator
Posts: 79447
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Rule Action Type

Post by HansV »

Weird - I created a (dummy) rule to be executed when I send a message:

S3406.png

When I run your code, it displays the name of the rule in the Immediate window, as intended:

S3407.png

Does your rule have a valid name? (Grasping at straws here...)
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Rule Action Type

Post by jstevens »

Hans,

I tried it again with a rename of the rule and same error message was returned.

Try modifying your rule to match mine.

The only thing I can think of is that the "action" icon is different from the incoming rules.
EL_89.png
The "Sent Items" is a local folder not the one on Gmail.
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
HansV
Administrator
Posts: 79447
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Rule Action Type

Post by HansV »

You will probably see the rule if you list the rules for the account that the Sent Items folder belongs to.
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Rule Action Type

Post by jstevens »

Hans,

All rules are under one account and can be confirmed by this line of code. MsgBox Rules.count 'This returns the correct number of rules including the one based on "sent"

I reordered the rules and now have the "sent" rule at the bottom of the rule list.

This bit of code works which excludes the last rule

Code: Select all

Msgbox Rules.count   'This returns the correct number of rules including the one based on "sent"

For i = 1 to Rules.count -1
	Debug.print Rules(i).Name
Next i

Regards,
John

User avatar
HansV
Administrator
Posts: 79447
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Rule Action Type

Post by HansV »

The ways of Microsoft are inscrutable...
Best wishes,
Hans