email message composition

50 views
Skip to first unread message

Pierre

unread,
Sep 20, 2016, 7:39:51 AM9/20/16
to web2py-users
Hi,

Trying to make a task compose email messages including variables........ I don't see a "natural" way to handle this via string manipulation. Is there an alternative solution ?
what's the preferred/standard form for simple emails:  html, xml, text ?

Anthony

unread,
Sep 20, 2016, 8:31:55 AM9/20/16
to web2py-users
Hard to say without seeing an example. With Python string formatting, you can used named placeholders and fill them with a dictionary. Alternatively, you could use a web2py template (either stored in a "view" file or simply as a string in your code). If you want to build an HTML email, you could also use web2py's HTML helpers.

Anthony

Jim S

unread,
Sep 20, 2016, 9:07:22 AM9/20/16
to web2py-users
I always create HTML emails.

I've used 3 different methods over the years.

1. Write the HTML using python string formatting
2. Use the Python Dominate package to build the HTML strings - https://github.com/Knio/dominate

I think the web2py templating is the easiest and most natural way to do it for web2py coders.

-Jim

Pierre

unread,
Sep 20, 2016, 1:48:06 PM9/20/16
to web2py-users
thanks guys

now works like a charm

I just mispelled the view name......(error_level=3, exitcode=56242)

Jim's number 3 does the job  :

response.render('message.html', context)


Dave S

unread,
Sep 20, 2016, 2:05:15 PM9/20/16
to web...@googlegroups.com

Glad to hear it's working for you!

(I use #1, but I'm only sending 1 email that consists of simple boilerplate and a string built up with my results. Some results are from the DB and some from the file system.)

/dps

Reply all
Reply to author
Forward
0 new messages