How to create Exchange 2000 Mailbox Rules programmatically - Microsoft Exchange

This is a discussion on How to create Exchange 2000 Mailbox Rules programmatically - Microsoft Exchange ; I need to create a rule on 170 Mailboxes (English & Spanish) located on a single server, single store that will move emails base on the Message Header to a SPAM Folder within the same Mailbox. Search for "X-Spam-Flag: YES" ...

+ Reply to Thread
Results 1 to 6 of 6

How to create Exchange 2000 Mailbox Rules programmatically

  1. Default How to create Exchange 2000 Mailbox Rules programmatically

    I need to create a rule on 170 Mailboxes (English & Spanish) located on a
    single server, single store that will move emails base on the Message Header
    to a SPAM Folder within the same Mailbox.

    Search for "X-Spam-Flag: YES" or
    X-SpamInfo: spam detected heuristically.

    I have Administrator Full rights on all mailboxes, A client base or server
    base will work for me




  2. Default Re: How to create Exchange 2000 Mailbox Rules programmatically

    You can use the Rule.dll to create Inbox rules programmatically with CDO
    have a look at http://support.microsoft.com/default.aspx?kbid=251125

    You might also want to consider using a Event sink instead of a rule you can
    get more information on creating and using Event sinks in the Exchange SDK
    which you can download from http://msdn.microsoft.com/exchange . You might
    also want to have a look at http://www.ivasoft.biz/spammover.shtml

    Cheers
    Glen

    "Manuel Paz" <Manuel Paz@discussions.microsoft.com> wrote in message
    news:16C84A93-A470-4A67-A72C-BA352006DB95@microsoft.com...
    > I need to create a rule on 170 Mailboxes (English & Spanish) located on a
    > single server, single store that will move emails base on the Message

    Header
    > to a SPAM Folder within the same Mailbox.
    >
    > Search for "X-Spam-Flag: YES" or
    > X-SpamInfo: spam detected heuristically.
    >
    > I have Administrator Full rights on all mailboxes, A client base or server
    > base will work for me
    >
    >
    >




  3. Default Re: How to create Exchange 2000 Mailbox Rules programmatically

    I have Exchange 2000. rules.dll runs on 5.5. Iwould prefer to run a vbs
    script to create the rules on each folder.

    Is there any rules.dll for Exchange 2000 ?



    "Glen Scales [MVP]" wrote:

    > You can use the Rule.dll to create Inbox rules programmatically with CDO
    > have a look at http://support.microsoft.com/default.aspx?kbid=251125
    >
    > You might also want to consider using a Event sink instead of a rule you can
    > get more information on creating and using Event sinks in the Exchange SDK
    > which you can download from http://msdn.microsoft.com/exchange . You might
    > also want to have a look at http://www.ivasoft.biz/spammover.shtml
    >
    > Cheers
    > Glen
    >
    > "Manuel Paz" <Manuel Paz@discussions.microsoft.com> wrote in message
    > news:16C84A93-A470-4A67-A72C-BA352006DB95@microsoft.com...
    > > I need to create a rule on 170 Mailboxes (English & Spanish) located on a
    > > single server, single store that will move emails base on the Message

    > Header
    > > to a SPAM Folder within the same Mailbox.
    > >
    > > Search for "X-Spam-Flag: YES" or
    > > X-SpamInfo: spam detected heuristically.
    > >
    > > I have Administrator Full rights on all mailboxes, A client base or server
    > > base will work for me
    > >
    > >
    > >

    >
    >
    >


  4. Default Re: How to create Exchange 2000 Mailbox Rules programmatically

    They haven't updated the rule.dll since exchange 5.5 but it works fine on
    Exchange 2000 and 2003. Eg the following VBS code uses the rule.dll to
    create a rule to move message that are "SPAM:" Subject tagged by a firewall
    to the Junk E-mail folder. I use this on a Exchange 2003 box without any
    problems the only pain with the rule.dll is that you can't access the rules
    it creates using Outlook. The copy of rule.dll i use you can download from
    http://www.cdolive.net/download/ruleasp.zip

    Cheers
    Glen

    Const ACTION_MOVE = 1
    Const CdoPR_SUBJECT = &H37001E
    Const IGNORECASE = &H10000
    Set objRules = CreateObject("MSExchange.Rules")
    Set objRule = CreateObject("MSExchange.Rule")
    Set objPropVal = CreateObject("MSExchange.PropertyValue")
    Set objAction = CreateObject("MSExchange.Action")
    Set objContCond = CreateObject("MSExchange.ContentCondition")
    set objSession = CreateObject("MAPI.Session")
    strProfile = "MailServer" & vbLf & "MailboxAlias"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox

    Set CdoInfoStore = objSession.GetInfoStore
    Set CdoFolderRoot = CdoInfoStore.RootFolder
    Set CdoFolders = CdoFolderRoot.Folders

    bFound = False
    Set CdoFolder = CdoFolders.GetFirst
    Do While (Not bFound) And Not (CdoFolder Is Nothing)
    If CdoFolder.Name = "Junk E-mail" Then
    bFound = True
    Else
    Set CdoFolder = CdoFolders.GetNext
    End If
    Loop
    Set ActionFolder = CdoFolder

    objRules.Folder = objInbox
    objPropVal.Tag = CdoPR_SUBJECT
    objPropVal.Value = "SPAM:"
    objContCond.Value = objPropVal
    objContCond.PropertyType = CdoPR_SUBJECT
    objContCond.Operator = 1 + IGNORECASE
    objAction.ActionType = ACTION_MOVE
    objAction.Arg = ActionFolder
    objRule.Name = "Move rule for Spam Tagging"
    objRule.Condition = objContCond
    objRule.Actions.Add ,objAction
    objRules.add , objRule
    objRules.update
    objsession.Logoff

    "Manuel Paz" <ManuelPaz@discussions.microsoft.com> wrote in message
    news:FD3FDFC4-81E1-4A7D-8900-F70DA32D3F23@microsoft.com...
    > I have Exchange 2000. rules.dll runs on 5.5. Iwould prefer to run a vbs
    > script to create the rules on each folder.
    >
    > Is there any rules.dll for Exchange 2000 ?
    >
    >
    >
    > "Glen Scales [MVP]" wrote:
    >
    > > You can use the Rule.dll to create Inbox rules programmatically with CDO
    > > have a look at http://support.microsoft.com/default.aspx?kbid=251125
    > >
    > > You might also want to consider using a Event sink instead of a rule you

    can
    > > get more information on creating and using Event sinks in the Exchange

    SDK
    > > which you can download from http://msdn.microsoft.com/exchange . You

    might
    > > also want to have a look at http://www.ivasoft.biz/spammover.shtml
    > >
    > > Cheers
    > > Glen
    > >
    > > "Manuel Paz" <Manuel Paz@discussions.microsoft.com> wrote in message
    > > news:16C84A93-A470-4A67-A72C-BA352006DB95@microsoft.com...
    > > > I need to create a rule on 170 Mailboxes (English & Spanish) located

    on a
    > > > single server, single store that will move emails base on the Message

    > > Header
    > > > to a SPAM Folder within the same Mailbox.
    > > >
    > > > Search for "X-Spam-Flag: YES" or
    > > > X-SpamInfo: spam detected heuristically.
    > > >
    > > > I have Administrator Full rights on all mailboxes, A client base or

    server
    > > > base will work for me
    > > >
    > > >
    > > >

    > >
    > >
    > >




  5. Default Re: How to create Exchange 2000 Mailbox Rules programmatically

    The code works great. I can live without accesing them through outlook. After
    creating the rule, the rule appears as ReadOnly.

    How can I delete a rule after creating them ?

    "Glen Scales [MVP]" wrote:

    > They haven't updated the rule.dll since exchange 5.5 but it works fine on
    > Exchange 2000 and 2003. Eg the following VBS code uses the rule.dll to
    > create a rule to move message that are "SPAM:" Subject tagged by a firewall
    > to the Junk E-mail folder. I use this on a Exchange 2003 box without any
    > problems the only pain with the rule.dll is that you can't access the rules
    > it creates using Outlook. The copy of rule.dll i use you can download from
    > http://www.cdolive.net/download/ruleasp.zip
    >
    > Cheers
    > Glen
    >
    > Const ACTION_MOVE = 1
    > Const CdoPR_SUBJECT = &H37001E
    > Const IGNORECASE = &H10000
    > Set objRules = CreateObject("MSExchange.Rules")
    > Set objRule = CreateObject("MSExchange.Rule")
    > Set objPropVal = CreateObject("MSExchange.PropertyValue")
    > Set objAction = CreateObject("MSExchange.Action")
    > Set objContCond = CreateObject("MSExchange.ContentCondition")
    > set objSession = CreateObject("MAPI.Session")
    > strProfile = "MailServer" & vbLf & "MailboxAlias"
    > objSession.Logon "",,, False,, True, strProfile
    > Set objInbox = objSession.Inbox
    >
    > Set CdoInfoStore = objSession.GetInfoStore
    > Set CdoFolderRoot = CdoInfoStore.RootFolder
    > Set CdoFolders = CdoFolderRoot.Folders
    >
    > bFound = False
    > Set CdoFolder = CdoFolders.GetFirst
    > Do While (Not bFound) And Not (CdoFolder Is Nothing)
    > If CdoFolder.Name = "Junk E-mail" Then
    > bFound = True
    > Else
    > Set CdoFolder = CdoFolders.GetNext
    > End If
    > Loop
    > Set ActionFolder = CdoFolder
    >
    > objRules.Folder = objInbox
    > objPropVal.Tag = CdoPR_SUBJECT
    > objPropVal.Value = "SPAM:"
    > objContCond.Value = objPropVal
    > objContCond.PropertyType = CdoPR_SUBJECT
    > objContCond.Operator = 1 + IGNORECASE
    > objAction.ActionType = ACTION_MOVE
    > objAction.Arg = ActionFolder
    > objRule.Name = "Move rule for Spam Tagging"
    > objRule.Condition = objContCond
    > objRule.Actions.Add ,objAction
    > objRules.add , objRule
    > objRules.update
    > objsession.Logoff
    >
    > "Manuel Paz" <ManuelPaz@discussions.microsoft.com> wrote in message
    > news:FD3FDFC4-81E1-4A7D-8900-F70DA32D3F23@microsoft.com...
    > > I have Exchange 2000. rules.dll runs on 5.5. Iwould prefer to run a vbs
    > > script to create the rules on each folder.
    > >
    > > Is there any rules.dll for Exchange 2000 ?
    > >
    > >
    > >
    > > "Glen Scales [MVP]" wrote:
    > >
    > > > You can use the Rule.dll to create Inbox rules programmatically with CDO
    > > > have a look at http://support.microsoft.com/default.aspx?kbid=251125
    > > >
    > > > You might also want to consider using a Event sink instead of a rule you

    > can
    > > > get more information on creating and using Event sinks in the Exchange

    > SDK
    > > > which you can download from http://msdn.microsoft.com/exchange . You

    > might
    > > > also want to have a look at http://www.ivasoft.biz/spammover.shtml
    > > >
    > > > Cheers
    > > > Glen
    > > >
    > > > "Manuel Paz" <Manuel Paz@discussions.microsoft.com> wrote in message
    > > > news:16C84A93-A470-4A67-A72C-BA352006DB95@microsoft.com...
    > > > > I need to create a rule on 170 Mailboxes (English & Spanish) located

    > on a
    > > > > single server, single store that will move emails base on the Message
    > > > Header
    > > > > to a SPAM Folder within the same Mailbox.
    > > > >
    > > > > Search for "X-Spam-Flag: YES" or
    > > > > X-SpamInfo: spam detected heuristically.
    > > > >
    > > > > I have Administrator Full rights on all mailboxes, A client base or

    > server
    > > > > base will work for me
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  6. Default Re: How to create Exchange 2000 Mailbox Rules programmatically

    There are a couple of way you could tackle this, the easy way should be just
    to use the rule.dll to delete it. With the rule.dll you can only delete
    rules that where created with rule.dll have a read of the note in
    http://msdn.microsoft.com/library/de...asp?frame=true .
    So the following code works for me to delete the rule that was created with
    the other code I posted. (other ways would be to search the mailbox using
    WebDAV or Exoledb and find and delete the object).

    Cheers
    Glen

    Set objRules = CreateObject("MSExchange.Rules")
    set objSession = CreateObject("MAPI.Session")
    strProfile = "server" & vbLf & "mailboxalias"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox
    objRules.folder = objInbox
    for each objrule in objrules
    wscript.echo objrule.Name & " " & objrule.ReadOnly & " " & objrule.index
    if objrule.Name = "Move rule for Spam Tag" then
    objrules.delete objrule.index
    objrules.update
    end if
    next


    "Manuel Paz" <ManuelPaz@discussions.microsoft.com> wrote in message
    news:ED056D43-B309-49E4-A6B5-D6057A28B942@microsoft.com...
    > The code works great. I can live without accesing them through outlook.

    After
    > creating the rule, the rule appears as ReadOnly.
    >
    > How can I delete a rule after creating them ?
    >
    > "Glen Scales [MVP]" wrote:
    >
    > > They haven't updated the rule.dll since exchange 5.5 but it works fine

    on
    > > Exchange 2000 and 2003. Eg the following VBS code uses the rule.dll to
    > > create a rule to move message that are "SPAM:" Subject tagged by a

    firewall
    > > to the Junk E-mail folder. I use this on a Exchange 2003 box without any
    > > problems the only pain with the rule.dll is that you can't access the

    rules
    > > it creates using Outlook. The copy of rule.dll i use you can download

    from
    > > http://www.cdolive.net/download/ruleasp.zip
    > >
    > > Cheers
    > > Glen
    > >
    > > Const ACTION_MOVE = 1
    > > Const CdoPR_SUBJECT = &H37001E
    > > Const IGNORECASE = &H10000
    > > Set objRules = CreateObject("MSExchange.Rules")
    > > Set objRule = CreateObject("MSExchange.Rule")
    > > Set objPropVal = CreateObject("MSExchange.PropertyValue")
    > > Set objAction = CreateObject("MSExchange.Action")
    > > Set objContCond = CreateObject("MSExchange.ContentCondition")
    > > set objSession = CreateObject("MAPI.Session")
    > > strProfile = "MailServer" & vbLf & "MailboxAlias"
    > > objSession.Logon "",,, False,, True, strProfile
    > > Set objInbox = objSession.Inbox
    > >
    > > Set CdoInfoStore = objSession.GetInfoStore
    > > Set CdoFolderRoot = CdoInfoStore.RootFolder
    > > Set CdoFolders = CdoFolderRoot.Folders
    > >
    > > bFound = False
    > > Set CdoFolder = CdoFolders.GetFirst
    > > Do While (Not bFound) And Not (CdoFolder Is Nothing)
    > > If CdoFolder.Name = "Junk E-mail" Then
    > > bFound = True
    > > Else
    > > Set CdoFolder = CdoFolders.GetNext
    > > End If
    > > Loop
    > > Set ActionFolder = CdoFolder
    > >
    > > objRules.Folder = objInbox
    > > objPropVal.Tag = CdoPR_SUBJECT
    > > objPropVal.Value = "SPAM:"
    > > objContCond.Value = objPropVal
    > > objContCond.PropertyType = CdoPR_SUBJECT
    > > objContCond.Operator = 1 + IGNORECASE
    > > objAction.ActionType = ACTION_MOVE
    > > objAction.Arg = ActionFolder
    > > objRule.Name = "Move rule for Spam Tagging"
    > > objRule.Condition = objContCond
    > > objRule.Actions.Add ,objAction
    > > objRules.add , objRule
    > > objRules.update
    > > objsession.Logoff
    > >
    > > "Manuel Paz" <ManuelPaz@discussions.microsoft.com> wrote in message
    > > news:FD3FDFC4-81E1-4A7D-8900-F70DA32D3F23@microsoft.com...
    > > > I have Exchange 2000. rules.dll runs on 5.5. Iwould prefer to run a

    vbs
    > > > script to create the rules on each folder.
    > > >
    > > > Is there any rules.dll for Exchange 2000 ?
    > > >
    > > >
    > > >
    > > > "Glen Scales [MVP]" wrote:
    > > >
    > > > > You can use the Rule.dll to create Inbox rules programmatically with

    CDO
    > > > > have a look at http://support.microsoft.com/default.aspx?kbid=251125
    > > > >
    > > > > You might also want to consider using a Event sink instead of a rule

    you
    > > can
    > > > > get more information on creating and using Event sinks in the

    Exchange
    > > SDK
    > > > > which you can download from http://msdn.microsoft.com/exchange .

    You
    > > might
    > > > > also want to have a look at http://www.ivasoft.biz/spammover.shtml
    > > > >
    > > > > Cheers
    > > > > Glen
    > > > >
    > > > > "Manuel Paz" <Manuel Paz@discussions.microsoft.com> wrote in message
    > > > > news:16C84A93-A470-4A67-A72C-BA352006DB95@microsoft.com...
    > > > > > I need to create a rule on 170 Mailboxes (English & Spanish)

    located
    > > on a
    > > > > > single server, single store that will move emails base on the

    Message
    > > > > Header
    > > > > > to a SPAM Folder within the same Mailbox.
    > > > > >
    > > > > > Search for "X-Spam-Flag: YES" or
    > > > > > X-SpamInfo: spam detected heuristically.
    > > > > >
    > > > > > I have Administrator Full rights on all mailboxes, A client base

    or
    > > server
    > > > > > base will work for me
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




+ Reply to Thread

Similar Threads

  1. Problems with Adding Rules Programmatically (Rules.dll) -- BUG?
    By Application Development in forum Microsoft Exchange
    Replies: 5
    Last Post: 08-29-2006, 09:06 AM
  2. Creating Exchange 2000/2003 Mailbox Rules programmatically via Rule.DLL
    By Application Development in forum Microsoft Exchange
    Replies: 5
    Last Post: 08-07-2006, 06:20 AM
  3. Programmatically Create Calendar Items in mailbox store
    By Application Development in forum Microsoft Exchange
    Replies: 2
    Last Post: 12-05-2005, 04:00 PM
  4. Programmatically Retrieve Exchange 2000 Mailbox Size
    By Application Development in forum Microsoft Exchange
    Replies: 1
    Last Post: 10-11-2004, 05:37 PM
  5. Unable to Create Mailbox on Exchange 2000
    By Application Development in forum Microsoft Exchange
    Replies: 1
    Last Post: 06-01-2004, 01:24 PM