繁体   English   中英

通过win32com使用python在Outlook中更改“来自”字段选项

[英]Change “from” field option in outlook using python via win32com

除了此线程通过win32com发送Outlook邮件外 ,我想知道是否有可能使用mail.From类似方法。 当你创建一个电子邮件,你可以从你想什么电子邮件发送它选择。 而对于未来,在那里我能得到这个信息? 我的意思是做这些命令与Outlook应用程序的COM对象的工作吗?

这是我使用了很长时间的代码,希望也能为您服务,

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM