You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python用win32com从Outlook次要邮箱发件遇权限问题求助

Outlook代理发送邮件权限报错(手动发送正常)

使用Python通过win32com操作Outlook发送邮件时遇到权限问题,代码如下:

outlook = win32com.client.Dispatch('outlook.application')
accounts = win32com.client.Dispatch("outlook.Application").Session.Accounts
print(accounts[1])
mail = outlook.CreateItem(0)
mail.SentOnBehalfOfName = accounts[1]
mail.SendUsingAccount = accounts[1]
mail.To = to
mail.Subject = 'Subject TEST'
mail.HTMLBody = emailBody
mail.display()
mail.Send()

相关现象:

  • 注释掉mail.Send()时,弹出的邮件窗口显示正常,发件人设置符合预期
  • 直接调用mail.Send()时,触发权限报错:

This message could not be sent. You do not have the permission to send the message on behalf of the specified user.

  • 手动在邮件窗口的发件人下拉菜单选择同一邮箱后发送,无任何权限问题

内容的提问来源于stack exchange,提问作者B-DK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 09:10:28