Automated email response

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tonydevlin

    #1

    Automated email response


    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.getM emberById(creat or)
    creator = {'member':membe r,
    'id':member.get Id(),
    'fullname':memb er.getProperty( 'fullname', 'Fullname missing'),
    'email':member. getProperty('em ail', None)}

    actorid = wf_tool.getInfo For(obj, 'actor')
    actor = context.portal_ membership.getM emberById(actor id)
    reviewer = {'member':actor ,
    'id':actor.getI d(),
    'fullname':acto r.getProperty(' fullname', 'Fullname missing'),
    'email':actor.g etProperty('ema il', None)}

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

    message = mMsg % (obj_url, comments)
    context.MailHos t.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.ob ject
    mship = context.portal_ membership
    mhost = context.MailHos t
    administratorEm ailAddress = context.email_f rom_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.listMembe rs():
    if "Reviewer" in mship.getMember ById(user.id).g etRoles():
    if user.email:
    msg = message % (
    administratorEm ailAddress,
    user.email,
    object.TitleOrI d(),
    object.Descript ion(),
    object.absolute _url()
    )
    mhost.send(msg)

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

Working...