In addition to this thread send outlook mail via win32com, i'd like to know if there is a possibility to use mail.From
alike method. When you create an email, you can choose from what email you'd like to send it.
And for the future, where could i get this information from? I mean do those commands work with COM object of outlook application?
Asked
Active
Viewed 1,961 times
2
-
I don't know if it's possible with win32com but this can be done using smtplib. – VIKASH JAISWAL Dec 10 '13 at 11:26
-
@VIKASH JAISWAL, can you provide possible solution or lead to an idea, thanks! – izdi Dec 10 '13 at 12:31
1 Answers
1
Here's a code which I have been using for long time and hopefully will work for you as well,
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
def sendMail(to, subject, text):
assert type(to)==list
fro = "abc@xyz.com" # use your from email here
msg = MIMEMultipart()
msg['From'] = fro
msg['To'] = COMMASPACE.join(to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach(MIMEText(html, 'html'))
smtp = smtplib.SMTP('mailhost.abcd.co.in') #use your mailhost here, it's dummy.
smtp.sendmail("", to, msg.as_string() )
smtp.close()
TOADDR = ['abc@xyz.com'] # list of emails address to be sent to
html = """\
<html>
<head></head>
<body>
<p>Hi!<br>
How are you?<br>
Here is the <a href="http://www.python.org">link</a> you wanted.
</p>
</body>
</html>
"""
sendMail( TOADDR, "hello",html)

VIKASH JAISWAL
- 828
- 1
- 5
- 11
-
-
Since I have never used something like that so don't know about it but I see there are other libraries that have. For instance look at this link: http://stackoverflow.com/questions/18156485/receve-replys-from-gmail-with-smtplib-python – VIKASH JAISWAL Dec 11 '13 at 06:07