【问题标题】:Send Outlook Appointment from Different Email Address从不同的电子邮件地址发送 Outlook 约会
【发布时间】:2018-07-10 00:29:40
【问题描述】:

尝试通过 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 = 'recipient@example.com'
sender = 'sender@example.com'

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

当我将电子邮件发送给我的同事时,即使发件人不是我的电子邮件地址,他也会收到来自我的个人电子邮件而不是“sender@example.com”的邀请

【问题讨论】:

    标签: python email outlook calendar


    【解决方案1】:

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

    【讨论】:

    • 有没有办法从辅助电子邮件发送?我有我的主帐户,但也可以通过 Outlook 将电子邮件发送到辅助帐户。
    • 您的意思是单独的邮箱帐户吗?还是链接到您的主要 Exchange 邮箱的委托存储?
    • 单独的邮箱帐号
    • 然后您只需要在该邮箱中创建约会 - 而不是 Application.CreateItem,从 Namespace.Stores 集合中获取正确的存储,使用 Store.GetDefaultFolder 打开默认日历文件夹,调用 MAPIFolder.Items .添加
    • 嗨,Dmitry,感谢您再次跟进。你能发布一个例子吗?我一直在尝试解决这个问题,但到目前为止一直没有成功!
    猜你喜欢
    • 2016-05-22
    • 2014-08-03
    • 1970-01-01
    • 2014-02-14
    • 2014-10-16
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    相关资源
    最近更新 更多