Christopher Long
2009-09-08 05:08:02 UTC
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]
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]