Jump to content
Sign in to follow this  

Exchange server rules

Recommended Posts



how can I read the rules from exchange server in autoit? I have a domain with active directory with mail object. I query it with ldap. What are attributes for a rule that forward mail to another user?

Sorry for my english.


Share this post

Link to post
Share on other sites


Did a quick translation of something I found on Google.

#include <date.au3>

Const $ACTION_MOVE = 1
Const $CdoPR_SUBJECT = 0x37001E
Const $IGNORECASE = 0x10000

$objRules = ObjCreate("MSExchange.Rules")
$objRule = ObjCreate("MSExchange.Rule")
$objPropVal = ObjCreate("MSExchange.PropertyValue")
$objAction = ObjCreate("MSExchange.Action")
$objContCond = ObjCreate("MSExchange.ContentCondition")
$objSession = ObjCreate("MAPI.Session")

$strProfile = "MailServer" & @LF & "MailboxAlias"
$objSession.Logon("",Default,Default, 0,Default, 1, $strProfile)
$objInbox = $objSession.Inbox

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

$bFound = 0
$CdoFolder = $CdoFolders.GetFirst

    If $CdoFolder.Name = "Junk E-mail" Then
        $bFound = 1
        $CdoFolder = $CdoFolders.GetNext

    $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)
While (Not $bFound) And Not ($CdoFolder = "")

Not tested of course



Share this post

Link to post
Share on other sites

Thanks for your answer and Im' sorry for my delay. Your script work for logged store mail with user and password. I'm trying to read the rules through Redemption.RDOSession object without logging.

Many thanks

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.