从不同的电子邮件地址发送 Outlook 预约

2023-12-03

尝试通过 python 发送 Outlook 日历邀请来自动化日历通知。我想从一个单独的电子邮件地址发送电子邮件。在python的email包中,可以使用sendmail()指定from_address和to_address;但是,我似乎不知道如何通过 win32com.client 进行 Outlook 邀请。

我已经尝试使用icalendar包来自动化这个过程,但是附加到电子邮件的ics文件“无法识别”。

使用 win32com.client,我已经能够在邀请中生成我想要的所有内容;但是,我仍然无法弄清楚如何指定发件人。

import win32com.client as win32
from datetime import datetime
import pytz
tz = pytz.timezone("US/Pacific")

start_time = tz.localize(datetime(2018, 2, 01, 16))
subject = 'The Best Meeting Ever'
duration = 30
location = 'Home'

recipient = '[email protected]'
sender = '[email protected]'

outlook = win32.Dispatch('outlook.application')
# CreateItem: 1 -- Outlook Appointment Item
appt = outlook.CreateItem(1) 

# set the parameters of the meeting
appt.Start = start_time
appt.Duration = duration
appt.Location = location
appt.Subject = subject

appt.MeetingStatus = 1 # this enables adding of recipients
appt.Recipients.Add(recipient)
appt.Organizer = sender
appt.ReminderMinutesBeforeStart = 15
appt.ResponseRequested = True
appt.Save()
appt.Send()

当我向同事发送电子邮件时,即使发件人不是我的电子邮件地址,他也会收到来自我的个人电子邮件的邀请,而不是“[电子邮件受保护]'


Outlook/Exchange 不会让您欺骗发件人相关属性 - 会议邀请将以当前 Outlook 用户的身份发送。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从不同的电子邮件地址发送 Outlook 预约 的相关文章

随机推荐