Sign in to follow this  
Followers 0
tamagogi

Exchange server rules

3 posts in this topic

Hi,

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.

Thanks

Share this post


Link to post
Share on other sites



@tamagogi

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

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

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

Not tested of course

rgds

ptrex

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