Automated email response

tonydevlin anthonydevine69 at hotmail.com
Sat Apr 7 08:24:31 EDT 2007


I currently have the python code 
obj=sti.object 
creator = obj.Creator() 
history = sti.getHistory() 
wf_tool = context.portal_workflow 

mMsg = """ 
Content has been submitted for your review. 
The url was %s. 
The reason was %s. 
""" 

member = context.portal_membership.getMemberById(creator) 
creator = {'member':member, 
           'id':member.getId(), 
           'fullname':member.getProperty('fullname', 'Fullname missing'), 
           'email':member.getProperty('email', None)} 

actorid = wf_tool.getInfoFor(obj, 'actor') 
actor = context.portal_membership.getMemberById(actorid) 
reviewer = {'member':actor, 
            'id':actor.getId(), 
            'fullname':actor.getProperty('fullname', 'Fullname missing'), 
            'email':actor.getProperty('email', None)} 

mTo = reviewer['email'] 
mFrom = creator['email'] 
mSubj = 'Your item has transitioned' 
obj_url = obj.absolute_url() #use portal_url + relative_url 
comments = wf_tool.getInfoFor(obj, 'comments') 

message = mMsg % (obj_url, comments) 
context.MailHost.send(message, mTo, mFrom, mSubj) 

This is attached to a transitions in a workflow and when a user selects the
transition they are emailed. I want it to email all of the users or selected
members like managers.  How would I go about changing the above code to do
that? 

I have tried the following code from the definitve guide to plone book, but
it does not have any effect on my workflow and does not email anyone.  Is
there something that I need to change on my setting possibly in Plone to get
the email response working, I have set up my mailhost and this works because
when I add a new user it emails them. 

# the objects we need 
object = state_change.object 
mship = context.portal_membership 
mhost = context.MailHost 
administratorEmailAddress = context.email_from_address 
  
# the message format, %s will be filled in from data 
message = """ 
From: %s 
To: %s 
Subject: New item submitted for approval - %s 
  
%s 
  
URL: %s 
""" 

for user in mship.listMembers(): 
    if "Reviewer" in mship.getMemberById(user.id).getRoles(): 
        if user.email: 
            msg = message % ( 
                             administratorEmailAddress, 
                             user.email, 
                             object.TitleOrId(), 
                             object.Description(), 
                             object.absolute_url() 
                            ) 
            mhost.send(msg)

-- 
View this message in context: http://www.nabble.com/Automated-email-response-tf3540615.html#a9883575
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list