Thanks to both of you for this information. I was just about to post a very 
similar question, but I'm glad I checked the mailing list first!

I do have one other question though. I built a contact form and from a 
functionality standpoint there are no problems with it. I used the 
following to get the content of my input fields to be included in the 
e-mail: 
 mail.send(to=['xx...@gmail.com'], subject='xxxxx', message=', '.join('%s: 
%s' % (f, request.vars[f]) for f in db.message.fields). 
(My table is called 'message', which I now realize may not be a great idea.)

As Anthony explained earlier, this results in a comma-separated list:
id: None, your_name: Cindy, your_email: *xx...@gmail.com* , your_message: 
Hello world!

I would like to make a few subtle changes to this formatting. If possible, 
I'd prefer not to show 'id' at all, and I'd like to show "Sender's name: 
Cindy" instead of "your_name: Cindy" (for example). Here's an example:

Sender's name: Cindy
Sender's e-mail:  *xx...@gmail.com* 

Hello world! This is where my message text will be.



I've been looking for ways to set the formatting of an e-mail send through 
a web2py contact form, but I'm not having much luck. Any assistance or 
helpful links would be greatly appreciated. Thanks in advance!

- Cindy


On Tuesday, May 22, 2012 3:15:31 PM UTC-5, Anthony wrote:
>
>         mail.send(to=['s...@distrobeef.com'],subject='DistroBeef Retailer 
>> Contact',message='request.vars.
>>>
>>>
>>> distributor,request.vars.dba,request.vars.contactnum,request.vars.fax,request.vars.location,request.vars.locationtwo,request.vars.city,request.vars.state,request.vars.zip,
>>> request.vars.name,request.vars.contact,request.vars.email
>>
>> ')
>>
>
> Maybe something like:
>
> message=', '.join('%s: %s' % (k, v) for (k, v) in request.vars.iteritems
> ())
>
> That will give you a comma-separated list of key-value pairs. Note, 
> though, that they won't be in any particular order. If, for example, you 
> want them in the same order as the fields in the db table defintion, you 
> could do:
>
> message=', '.join('%s: %s' % (f, request.vars[f]) for f in db.post.fields)
>
> Anthony
>

On Tuesday, May 22, 2012 3:15:31 PM UTC-5, Anthony wrote:
>
>         mail.send(to=['s...@distrobeef.com'],subject='DistroBeef Retailer 
>> Contact',message='request.vars.
>>>
>>>
>>> distributor,request.vars.dba,request.vars.contactnum,request.vars.fax,request.vars.location,request.vars.locationtwo,request.vars.city,request.vars.state,request.vars.zip,
>>> request.vars.name,request.vars.contact,request.vars.email
>>
>> ')
>>
>
> Maybe something like:
>
> message=', '.join('%s: %s' % (k, v) for (k, v) in request.vars.iteritems
> ())
>
> That will give you a comma-separated list of key-value pairs. Note, 
> though, that they won't be in any particular order. If, for example, you 
> want them in the same order as the fields in the db table defintion, you 
> could do:
>
> message=', '.join('%s: %s' % (f, request.vars[f]) for f in db.post.fields)
>
> Anthony
>

Reply via email to