Bài viết phổ biến của tác giả
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 ms Outlook 中有 2 个帐户('user1@test.com' - 默认配置文件,'user2@test.com'),我正在尝试使用非默认帐户通过 python 发送消息。这是我的代码:
Import win32com.client
app = win32com.client.Dispatch('Outlook.application')
mess = app.CreateItem(0)
mess.to = 'user2@test.com'
mess.subject = 'hi'
mess.SendUsingAccount = 'user2@test.com'
mess.Send()
1 Câu trả lời
MailItem.SendUsingAccount属性允许设置 Accountthể hiện MailItem
所属帐户的对象将被发送。
import win32com.client
o = win32com.client.Dispatch("Outlook.Application")
oacctouse = None
for oacc in o.Session.Accounts:
if oacc.SmtpAddress == "user2@test.com":
oacctouse = oacc
phá vỡ
Msg = o.CreateItem(0)
if oacctouse:
Msg._oleobj_.Invoke(*(64209, 0, 8, 0, oacctouse)) # Msg.SendUsingAccount = oacctouse
if to:
Msg.To = ";".join(to)
if cc:
Msg.CC = ";".join(cc)
if bcc:
Msg.BCC = ";".join(bcc)
Msg.HTMLBody = ""
Msg.Send()
关于outlook - 在python 3中更改发件人帐户ms Outlook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58378722/
Tôi là một lập trình viên xuất sắc, rất giỏi!