以编程方式从共享邮箱发送Outlook电子邮件 [英] programmatically send outlook email from shared mailbox
问题描述
我正在尝试从共享邮箱中发送带有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中配置了多个帐户,则可以使用 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屋!