Exchangelib:将电子邮件作为通讯组列表发送
我正在使用 Exchangelib python EWS 库发送电子邮件。从我的邮箱发送按预期工作,但如何从已应用“发送为”权限的通讯组列表发送电子邮件(已在 Outlook 中测试更改发件人地址)?
以下代码段将发送电子邮件,但“[电子邮件受保护]”帐户显示为发件人。如果我将“access_type=DELEGATE”更改为“access_type=IMPERSONATION”,我会收到错误“ErrorNonExistentMailbox:SMTP 地址没有与之关联的邮箱。”。
credentials = Credentials("[email protected]", password)
config = Configuration(server=server, credentials=credentials)
account = Account(primary_smtp_address="[email protected]", config=config, autodiscover=False, access_type=DELEGATE)
message = Message(account=account,subject="subject",folder=None)
message.sender = "[email protected]"
message.to_recipients = "[email protected]"
message.body = "test"
message.send(save_copy=False, copy_to_folder=False)
非常感谢任何帮助或指导
I'm using the exchangelib python EWS library to send emails. Sending from my mailbox works as expected but how can I send an email from a distribution list I have "Send As" permissions already applied (Have tested in Outlook changing the from address)?
The below code snippet will send the email but "[email protected]" account shows as the sender. If I change "access_type=DELEGATE" to "access_type=IMPERSONATION", I receive an error "ErrorNonExistentMailbox: The SMTP address has no mailbox associated with it.".
credentials = Credentials("[email protected]", password)
config = Configuration(server=server, credentials=credentials)
account = Account(primary_smtp_address="[email protected]", config=config, autodiscover=False, access_type=DELEGATE)
message = Message(account=account,subject="subject",folder=None)
message.sender = "[email protected]"
message.to_recipients = "[email protected]"
message.body = "test"
message.send(save_copy=False, copy_to_folder=False)
Any help or guidance is very much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通讯组列表在 Exchange 中通常没有自己的邮箱,因此您不能使用其电子邮件地址作为帐户的
primary_smtp_address
。消息同时具有
sender
和author
字段。您可以尝试在author
字段中设置通讯组列表电子邮件。然后电子邮件可能会显示为来自该电子邮件地址。A distribution list usually doesn't have its own mailbox in Exchange, so you can't use its email address as
primary_smtp_address
for the account.Messages have both a
sender
and anauthor
field. You could try to set the distribution list email in theauthor
field. Then emails may show up as coming from that email address.