A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Redemption - Rules for outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 8th 09, 06:20 AM posted to microsoft.public.outlook.program_vba
Christopher Long
external usenet poster
 
Posts: 3
Default Redemption - Rules for outlook

Afternoon. Think i may have placed the last post in the wrong newsgroup so
please excuse the double post.

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.olFolder Inbox)
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 = ') 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)
Ads
  #2  
Old September 8th 09, 03:08 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Redemption - Rules for outlook

See my answer in the other group.

--
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


"Christopher Long" wrote in
message ...
Afternoon. Think i may have placed the last post in the wrong newsgroup so
please excuse the double post.

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.olFolder Inbox)
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 = ') 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)



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redemption & Outlook glm Outlook and VBA 1 May 17th 08 05:19 PM
Outlook Redemption - HELP Rob Outlook and VBA 7 June 23rd 07 11:38 PM
How to set CC @ Outlook Redemption Luk Outlook and VBA 8 November 9th 06 06:20 PM
How to set CC @ Outlook Redemption Luk Outlook - General Queries 2 November 8th 06 02:17 PM
Outlook Redemption fgibbcollins Outlook and VBA 2 March 16th 06 06:03 PM


All times are GMT +1. The time now is 04:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.