Automated email response

T

tonydevlin

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top