mailbox 编程,以编程方式从共享邮箱发送Outlook电子邮件

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.

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()

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?

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值