I was making a program yesterday that would send an email using the email modules of python as well as the smtp module.
My problem is when i put it into an exe using py2exe and vega's code snippet setup i get some problems. This is the error message i get when i try and run the .exe file:
Traceback (most recent call last):
File "email_program.py", line 2, in <module>
File "email\__init__.pyc", line 79, in __getattr__
ImportError: No module named multipart
The thing is that is works fine when i run it when it is not compiled into an exe. Im not that crash hot with py2exe so i was wondering is someone with a bit more idea with me could point me in the right direction. Here is my code for any reference.
import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email import Encoders import pythoncom, pyHook import os global s s = "" gmail_user = "*************" gmail_pwd = "************" def mail(to, subject, text): msg = MIMEMultipart() msg['From'] = gmail_user msg['To'] = to msg['Subject'] = subject msg.attach(MIMEText(text)) mailServer = smtplib.SMTP("smtp.gmail.com", 587) mailServer.ehlo() mailServer.starttls() mailServer.ehlo() mailServer.login(gmail_user, gmail_pwd) mailServer.sendmail(gmail_user, to, msg.as_string()) # Should be mailServer.quit(), but that crashes... mailServer.close() mail('firstname.lastname@example.org', 'subject', 'Hello from python')