以编程方式从共享邮箱发送 Outlook 电子邮件 [英] programmatically send outlook email from shared mailbox

查看:60
本文介绍了以编程方式从共享邮箱发送 Outlook 电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从共享邮箱中使用 python 发送电子邮件.

I'm trying to send an email with python from a shared mailbox.

我已经能够通过我自己的电子邮件成功地发送它,但是使用共享邮箱(我已经测试过我也可以访问)发送一个给我带来了问题.

I have been able to sucessfuly send it through my own email, but sending one with a shared mailbox (that I have tested that I have access too) is giving me issues.

python中用于电子邮件脚本的代码

Code used for email script in python

import win32com.client
import win32com
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "Python Email Test"
newMail.Body = "Test"
newMail.To = 'hi@hi.com'
newMail.Send()

我知道下面是我从共享文件夹中读取电子邮件的方法.<代码>Outlook = win32com.Dispatch("Outlook.Application").GetNamespace("MAPI")dir_accounts = Outlook.Folders("SharedFolder")

I know that below is how I can read my emails from a shared Folder. outlook = win32com.Dispatch("Outlook.Application").GetNamespace("MAPI") dir_accounts = outlook.Folders("SharedFolder")

关于如何组合这些有什么想法吗?

Any ideas on how to combine these?

推荐答案

如果您在 Outlook 中配置了多个帐户,您可以使用 SendUsingAccount 类的 MailItem 属性.或者,如果您有足够的特权(权限),您可以考虑使用 SentOnBehalfOfName 属性,它是一个字符串,指示邮件消息的预期发件人的显示名称.

In case if you have multiple accounts configured in Outlook you may use the SendUsingAccount property of the MailItem class. Or if you have sufficient privileges (rights) you may consider using the SentOnBehalfOfName property which is a string indicating the display name for the intended sender of the mail message.

这篇关于以编程方式从共享邮箱发送 Outlook 电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆