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
相关产品推荐
相关产品推荐

