En Fri, 28 Sep 2007 12:56:18 -0300, Mark Bratcher  
<[EMAIL PROTECTED]> escribi�:

> The quick screenshots script works great for the project I'm working on  
> and
> I'm trying to modify it to include emailing the JPG file it generates.  I
> retrieved both scripts from the Python Archives.  The modified script is
> pasted below and the errors below that.  My goal is to have the latest  
> date
> stamped file emailed to me.

> editorstring='"start"%s" "%s"'% (ImageEditorPath,saveas) #Just for  
> Windows
> right now?

Do you really want to open the image with MSPaint? If not, remove the  
above line and the os.system call
(it's wrong, anyway...)

> # me == the sender's email address
>
> # family = the list of all recipients' email addresses
>
> msg['From'] = ("Mark Bratcher")
>
> msg['To'] = COMMASPACE.join("Mark Bratcher")

Ouch... Try printing msg['To'] (before correcting anything) and see what  
happens :)

msg['From'] = "[EMAIL PROTECTED]"
msg['To'] = "[EMAIL PROTECTED]"

They might be the same address. That COMMASPACE.join was to account for  
multiple recipients - just ignore it for now.

> for file in "c:\downloads\python\Attachments\*.jpg":

a) This `for` iterates over all the LETTERS on c:\downloads...
b) The path should be written r"c:\downloads..." as seen on the first  
lines on your script
c) Don't you want a SINGLE jpg? Why iterate over all ones? You already  
know the filename, it's the `saveas` variable above.

Replace the whole for loop with:

# Open the files in binary mode.  Let the MIMEImage class automatically
fp = open(saveas, 'rb')
img = MIMEImage(fp.read())
fp.close()
msg.attach(img)

> # Send the email via our own SMTP server.
> s = smtplib.SMTP()

Above, you may need to provide details about your SMTP, like  
SMTP("mail.cclpcitrus.com")

> s.connect()
> s.sendmail(me, family, msg.as_string())
> s.close()

me? family?
Try with:
s.sendmail(msg['From'], msg['To'], msg.as_string())

Good luck!

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to