Discussion:
Redemption Rules - releasing com objects
(too old to reply)
Christopher Long
2009-09-08 05:08:02 UTC
Permalink
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.

All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.

I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).

Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.

Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder

MainInbox = Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)

[CODE]
Dim i As Integer
Dim strTestArray() As String

'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String

Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True

strConditions = "(SenderEmailAddress = '***@test.com') and (Body
like '%test%')"

subfolder = Inbox.Folders("Test")

For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"

' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")

actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True

rule.ConditionsAsSQL = strConditions

rule.Enabled = True
rule.Save()


Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)

GC.Collect()
' end temp

Debug.WriteLine(i)

Next i

MsgBox("test finished - " & i)

[/CODE]
Ken Slovak - [MVP - Outlook]
2009-09-08 13:59:47 UTC
Permalink
The code looks OK to me. Two suggestions.

First, although I doubt this is a factor, use Marshal.ReleaseComObject() as
the function that it is. For example:

Dim count As Integer = Marshal.ReleaseComObject(action)
If count <> 0 Then
Do While count <> 0
count = Marshal.ReleaseComObject(action)
Loop
End If

Second, instead of using a 1 To 100 loop run the loop 25 times and call it 4
times to make up the 100 iterations. See if that helps.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Sue Mosher [MVP]
2009-09-08 14:06:50 UTC
Permalink
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Christopher Long
2009-09-08 21:53:20 UTC
Permalink
Sue,

Not sure on what the max number of rules on an exchange mailbox is so if you
know and could tell me that would be great but i have a total of 4 rules on
my exchange box before i start adding rules. Surely one can have up to 200
rules at least on their exchange box? If not i'll have to look at another way
of doing it.

Basically i'm wanting to filter a bunch of scom alerts to folders. We have a
large bunch of servers around the state with names that in no way make it
clear what location they are at. Each IT staff member looks after a certain
set of servers so alot at pointless to them.

Basically the app creates a folder set (working fine) then a rule to filter
these incoming scom alerts into the appropriate folder e.g.

alerts
- location 1
- location 2
- location 3
- to location x

rule for each folder - if senderaddress = "***@alerts.com" and body like
locationserv1name
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Christopher Long
2009-09-08 22:24:22 UTC
Permalink
Sue i think you might have found the problem. Why is it that i can manually
go into outlook rules and alerts and keep adding them fine yet from code if i
create a button that just manually adds a single redemption rule it fails? Is
there a difference between how redemption rules are added and how the rules
in outlook are added?

Is this limit dependant on exchange server settings?

Its both weird and annoying. Do you see any solution around this rather than
having to tolerate around 54 rules which isn't really that large an amount?
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Sue Mosher [MVP]
2009-09-08 22:52:37 UTC
Permalink
If you can add a rule manually, then you're still within the limit. There is
no definite maximum number of rules. It depends on the individual rule
contents, but 54 isn't that many.

Sounds like Ken's ideas might be the ones to follow up next.

Another approach might be to use the Query Builder (see
http://blogs.officezealot.com/legault/archive/2009/09/03/21596.aspx) to
create complex search folder filters and avoid rules altogether.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Sue i think you might have found the problem. Why is it that i can manually
go into outlook rules and alerts and keep adding them fine yet from code if i
create a button that just manually adds a single redemption rule it fails? Is
there a difference between how redemption rules are added and how the rules
in outlook are added?
Is this limit dependant on exchange server settings?
Its both weird and annoying. Do you see any solution around this rather than
having to tolerate around 54 rules which isn't really that large an amount?
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past
after
a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are
created
on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be
better
if
i could fix it. Can someone try the below code / offer some
suggestions
on
how to correctly release all explicit and implict objects and vars
that
might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which
point
it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Christopher Long
2009-09-09 05:51:01 UTC
Permalink
Tried again with a slightly larger rule and it gives the error about disable
some rules or delete them so i'm definitely going over the limit. As with the
microsoft support item 40-50 rules is apparantly about the limit so i guess
thats what its at.

Only way around is to use outlook 2007 and exchange server 2007 which has
64KB default with you being able to alter it on a per mailbox basis up to a
total of 256KB. @ 50 rules per 32KB thats 400 rules which is sufficient. I
think thats the path i'll have to tread.

Most individuals only look after 30 locations so for now its sufficient.
I'll just have to catch the exception and deal with the not enough memory to
warn users they have hit their limit until exchange server 2007 is
implemented or i come up with a more elegant solution to filter mail alerts.

Thanks again for your help. Without this insight i'd still be scratching my
head. At least i understand it now and i've learnt something and really isn't
that whats important <grins>.
Post by Sue Mosher [MVP]
If you can add a rule manually, then you're still within the limit. There is
no definite maximum number of rules. It depends on the individual rule
contents, but 54 isn't that many.
Sounds like Ken's ideas might be the ones to follow up next.
Another approach might be to use the Query Builder (see
http://blogs.officezealot.com/legault/archive/2009/09/03/21596.aspx) to
create complex search folder filters and avoid rules altogether.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Sue i think you might have found the problem. Why is it that i can manually
go into outlook rules and alerts and keep adding them fine yet from code if i
create a button that just manually adds a single redemption rule it fails? Is
there a difference between how redemption rules are added and how the rules
in outlook are added?
Is this limit dependant on exchange server settings?
Its both weird and annoying. Do you see any solution around this rather than
having to tolerate around 54 rules which isn't really that large an amount?
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past
after
a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are
created
on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be
better
if
i could fix it. Can someone try the below code / offer some
suggestions
on
how to correctly release all explicit and implict objects and vars
that
might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which
point
it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Christopher Long
2009-09-08 22:33:15 UTC
Permalink
Taking Sue's suggestion i did some research and found this

http://support.microsoft.com/default.aspx/kb/147298

With the RPC calls for rule packings its typically 40-50 rules per folder.
Does outlook count subfolders as part of the upper folder when doing this
calculation?

e.g.

Alert Folder
- Alert Subfolder 1
- Alert Subfolder 2

So if i had a rule associated with Subfolder1 and a rule associated with
Subfolder2 would Alert Folders ruleset be the combined size of subfolder1 and
subfolder2? If so then that is the problem and i just have to make
additional Alert Folders.
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Sue Mosher [MVP]
2009-09-08 23:55:21 UTC
Permalink
I don't think there's any way to know for sure other than to try it. There
is no easy mechanism for extracting the size of a single rule, because
they're all held in a binary blob. However, folders are generally referenced
by EntryID not by name, so I don't think the location in the hierarchy
matters much.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by Christopher Long
Taking Sue's suggestion i did some research and found this
http://support.microsoft.com/default.aspx/kb/147298
With the RPC calls for rule packings its typically 40-50 rules per folder.
Does outlook count subfolders as part of the upper folder when doing this
calculation?
e.g.
Alert Folder
- Alert Subfolder 1
- Alert Subfolder 2
So if i had a rule associated with Subfolder1 and a rule associated with
Subfolder2 would Alert Folders ruleset be the combined size of subfolder1 and
subfolder2? If so then that is the problem and i just have to make
additional Alert Folders.
Post by Sue Mosher [MVP]
Are these rules in an Exchange mailbox? If so, you might also be running up
against the limit on the number of rules. The easy way to test that is to
see if, after encountering the error, you can add another rule manually.
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past
after
a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are
created
on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be
better
if
i could fix it. Can someone try the below code / offer some
suggestions
on
how to correctly release all explicit and implict objects and vars
that
might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which
point
it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Christopher Long
2009-09-08 22:31:15 UTC
Permalink
Ken,

I had the loop set as something high just to stress test it so i could see
where exactly it fails. Always seems to be 49 times. Check the thread below
with sues reply so i can keep it on track with my responses. If you could
take a look at that and comment i'd be grateful.
Post by Ken Slovak - [MVP - Outlook]
The code looks OK to me. Two suggestions.
First, although I doubt this is a factor, use Marshal.ReleaseComObject() as
Dim count As Integer = Marshal.ReleaseComObject(action)
If count <> 0 Then
Do While count <> 0
count = Marshal.ReleaseComObject(action)
Loop
End If
Second, instead of using a 1 To 100 loop run the loop 25 times and call it 4
times to make up the 100 iterations. See if that helps.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Ken Slovak - [MVP - Outlook]
2009-09-09 13:31:28 UTC
Permalink
It looks like Sue's idea of the rules limit is what's happening. Since I
just write code and almost never create more than a few routing rules that
hadn't occurred to me.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by Christopher Long
Ken,
I had the loop set as something high just to stress test it so i could see
where exactly it fails. Always seems to be 49 times. Check the thread below
with sues reply so i can keep it on track with my responses. If you could
take a look at that and comment i'd be grateful.
Dmitry Streblechenko
2009-09-10 06:32:36 UTC
Permalink
There is a problem with COM objects reference leaks in the current version
of Reemption wwhen you access rule properties.
Send an e-mail to my private e-mail address and I'll send you a version
with a fix for that problem (not yet publictly available).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Post by Christopher Long
Afternoon. I have been using the redemption dll as of late in order to
programatically created a bunch of rules to filter emails (around 144 rules
though this could be more or less) based on items in a csv file.
All is good except for 1 little issue i just can't get myself past after a
few days of googling and trial and error. Below is a listing of code that
causes an error after around 49 rules with associated objects are created on
my system.
I've followed the posting and google results on the RPC limits and
marshaling to release objects and i'm sure thats the problem. I get a mixture
of errors mostly MAPI_E_NOT_ENOUGH_MEMORY and MAPI_E_CALLBACK (i think thats
it).
Works wonderfully for less than 49 objects but obviously would be better if
i could fix it. Can someone try the below code / offer some suggestions on
how to correctly release all explicit and implict objects and vars that might
be causing the problems? I'd be most appreciative. Was good seeing the light
at the end of the tunnel till i realised it was a train :/ at which point it
was too late.
Public Inbox As Redemption.RDOFolder
Public MainInbox As Redemption.RDOFolder
MainInbox =
Store.GetDefaultFolder(DefaultInboxFolder.olFolderInbox)
Inbox = MainInbox.Folders(txtFolderName.Text)
[CODE]
Dim i As Integer
Dim strTestArray() As String
'temp test
Dim rule As Redemption.RDORule
Dim action As Redemption.RDORuleAction
Dim actions As Redemption.RDORuleActions
Dim subfolder As Redemption.RDOFolder
Dim strConditions As String
Debug.Listeners.Add(New
TextWriterTraceListener(System.AppDomain.CurrentDomain.BaseDirectory() &
"output.txt"))
Debug.AutoFlush = True
like '%test%')"
subfolder = Inbox.Folders("Test")
For i = 1 To 100
ReDim strTestArray(2)
strTestArray(0) = "testrule" & i
strTestArray(1) = "Test"
strTestArray(2) = "Test"
' begin temp
rule = rules.Create(strTestArray(0))
' subfolder = Inbox.Folders("Test")
actions = rule.Actions
action = actions.MoveToFolder
action.Folder = subfolder
action.Enabled = True
rule.ConditionsAsSQL = strConditions
rule.Enabled = True
rule.Save()
Marshal.ReleaseComObject(action)
Marshal.ReleaseComObject(actions)
Marshal.ReleaseComObject(rule)
GC.Collect()
' end temp
Debug.WriteLine(i)
Next i
MsgBox("test finished - " & i)
[/CODE]
Loading...