On Tue, 02 Sep 2014 05:05:41 +0530, Om Prakash wrote:

> fp = open("message", 'rb')

"message" here is a string literal

> fp.close

should be fp.close()

> msg['Subject']  = 'The contents of $s' % message

message here is a variable. The variable named message has not previously 
had a value assigned to it.
$s should be %s

If you want the subject to be the filename, then what you need to do is:

1) assign the filename to some variable
2) open the file using the variable that contains the filename
3) use the variable that contains the filename to generate the subject

eg (assuming suitable imports etc) and the message is in a text file 
called message.txt:
 
msgfile = "message.txt"
fp = open( msgfile, "r" )
msg = MIMEText(fp.read())
fp.close()
msg['Subject']  = 'The contents of %s' % msgfile

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to