Creating Rules in a mailbox using COM interface

HI,

Can any one have any idea to create a rule in a mailbox through COM objects ?

I have a code but it is creating somthing and it is saving it in the drafts not in the rules.

I dont’ know hot to we can set the field “$FilterFormula”.

My Code is :

import os,time

from win32com.client import Dispatch

#retcode = os.system("tasklist > "+“C:\tskl_2.txt”)

ses = Dispatch(‘Lotus.NotesSession’)

print repr(ses)

MY_NOTES_PASSWORD = “builder!12”

ses.Initialize(MY_NOTES_PASSWORD)

DominoServerName = “suse10sp3/autotest”

ndb = ses.GetDatabase(DominoServerName,“mail\bnas.nsf”)

print ndb.IsOpen

if ndb.IsOpen == False :

print "It is not created"

print “Creating documents…”

ndb.EnableFolder(“som”)

for i in range(1,2):

aDoc=ndb.CreateDocument()

aDoc.AppendItemValue( "Form", "Mailrule")

aDoc.Save(True,True)

aDoc.AppendItemValue( "$KeepPrivate", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "action", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "behavior", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "condition", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "ConditionListDisplay", "")

aDoc.Save(True,True)

aDoc.AppendItemValue( "ActionListDisplay", "")

aDoc.Save(True,True)

aDoc.AppendItemValue( "Enable", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "folder", "")

aDoc.Save(True,True)

aDoc.AppendItemValue( "Importance", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "importancecond", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "logic", "1")

aDoc.Save(True,True)

aDoc.AppendItemValue( "Operator", "0")

aDoc.Save(True,True)

aDoc.AppendItemValue( "TokActionList", "1|1|som")

aDoc.Save(True,True)

aDoc.AppendItemValue( "tokConditionList", "1|1|som|0")

aDoc.Save(True,True)

aDoc.AppendItemValue( "ConditionList", " Sender contains som")

aDoc.Save(True,True)

aDoc.AppendItemValue("ActionList"," move to folder som")

aDoc.Save(True,True)

Formula = "{CondSender_C := @LowerCase( @Name([Abbreviate]; @Unique( From:Principal:SMTPOrigi}(nator ) ) ) ; @If(( ( @Contains( CondSender_C ;"+"\""+"bingo"+"\""+")) ) ; (@Do((@MailFilterAdd}{ToFolder("+"\""+"09169A40699E1F83652577D80025F364"+"\""+"; @True)))); "+"\""+"\""+" )}"

aDoc.AppendItemValue( "$FilterFormula", Formula)

aDoc.Save(True,True)

flag = aDoc.ComputeWithForm( True, True  )

if flag == True:

    print "Documents created successfully"

else:

    print "There is som thing wrong internally while creating documents"

The formula whatever I am giving is it is taking as a String not a Formula

Please help me.

Thanks,

Somnath Naskar