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


Groups > comp.lang.python > #77421 > unrolled thread

Re: error while writing program to send mail.

Started byCameron Simpson <cs@zip.com.au>
First post2014-09-02 09:52 +1000
Last post2014-09-02 09:52 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#77421 — Re: error while writing program to send mail.

FromCameron Simpson <cs@zip.com.au>
Date2014-09-02 09:52 +1000
SubjectRe: error while writing program to send mail.
Message-ID<mailman.13700.1409615523.18130.python-list@python.org>
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>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web