Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77421

Re: error while writing program to send mail.

Date 2014-09-02 09:52 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: error while writing program to send mail.
References <540502CD.8030209@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13700.1409615523.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 02Sep2014 05:05, Om Prakash <torque.india@gmail.com> wrote:
>I am writing this program from 
>https://docs.python.org/2/library/email-examples.html
>
>but getting the error as
>
>singhom@debian:~/pythons$ python send_email.py
>Traceback (most recent call last):
>  File "send_email.py", line 18, in <module>
>    msg['Subject']  = 'The contents of $s' % message
>NameError: name 'message' is not defined
>
>i know the error would be something simple and i am overlooking it, 
>any help would be highly appreciated, I am sorry, but I am very new to 
>python programming.

This problem is generic to almost any programming language: you have not 
defined the variable "message" before you try to use it in the format string.

In the example code, the variable is called "textfile" and is supposed to be 
the name of a file containing some message text. The example code does not 
define it; you need to do so.

After you sort that, you then have a ython problem: you have said "$s" in your 
format string, but the python "%" operator expected "%s" in the format string.

Sort these two things and see how things proceed.

Cheers,
Cameron Simpson <cs@zip.com.au>

Personally, I find blinking text on a page to be extraordinarily annoying and
my first instinct is to back up one page, right away.
         - William Barr <wbarr@leland.stanford.edu>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: error while writing program to send mail. Cameron Simpson <cs@zip.com.au> - 2014-09-02 09:52 +1000

csiph-web