do you have a report_mail.txt in views ?
On Saturday, August 18, 2012 9:08:12 PM UTC+2, thinkwell wrote:
>
> Hello everyone,
>
> I'm working on emailing a message and I'm having some unexpected issues.
> Here is my code based on the web2py book:
>
> from gluon.tools import Mail
> from report_vars import *
>
> report_month = '7-2012'
>
> mail = Mail()
>
>
> mail.settings.server = 'smtp.gmail.com:587'
> mail.settings.sender = owner_email
> mail.settings.login = 'username:password'
>
> context = dict(person = comp_owner, company = company, report_month
> =report_month
> )
>
> message = response.render('report_email.txt', context)
>
> mail.send(to = ['[email protected] <javascript:>'],
> subject = 'Re-Test Function from Web2py',
> message = message,
> bcc = tech_email,
> attachments = Mail.Attachment('{0}_{1}_report.pdf'.format(
> company_no_spaces, report_month))
> )
>
>
> When I run the code in WingIDE, I get
> NameError: name 'response' is not defined.
>
> If I run in the web2py Shell the NameError isn't raised, but instead I
> get:
> HTTP: 404 NOT FOUND [invalid view (report_mail.txt)]
>
> What gives?
>
>
--