Can we create mail rule using COM objects

Hi,

Using COM objects I am able to create Calendar items but I am not able to create a Mail rule item .

I am tried to create it like :

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

It is creating as a document items and saving it in Drafts folder.Not able to see any rule in rules folder.

Any help from any one ?Please…

Thanks

Somnath Naskar

Subject: Forwarded to Enginering for investigation

Subject: Maybe

You need copy the existing rule item $FilterFormula which is a special type you cannot create with COM. You will need copy from a known working note and update it then save it back making sure not to change its type.