我想在 Outlook 中更改约会的时区和发件人

I want to change the timezone and the sender of the appointment in Outlook

我想将开始日期和结束日期的时区更改为CST(US/Central时间),我在这里编码的时间会自动转换为本地时间,因此将其放入[=后会发生变化11=] 为当地时间。 我还想知道如何将此约会的发件人更改为我将提供的 gmail。因为 appointment.Organizer = "gmail" 不起作用,appointment.SendUsingAccount = "gmail" 也不起作用

代码如下:

acc = ""
for account in session.Accounts:
    if account.AccountType == 1: #0 - outlookExchange, 1 - outlookIMAP, 2 - outlookPop3
        print(account)
        acc = account

def saveMeeting(start, end, subject, location, attachments, recipients):

    appointment = outlook.CreateItem(1) #1 - AppointmentItem

    # Fill in the data needed
    appointment.SendUsingAccount = acc
    appointment.StartTimeZone = outlook.TimeZones("Central Standard Time")
    appointment.Start = start #yyyy-MM-dd hh:mm:ss
    appointment.EndTimeZone = outlook.TimeZones("Central Standard Time")
    appointment.End = end #yyyy-MM-dd hh:mm:ss
    appointment.Subject = subject
    appointment.Location = location
    appointment.MeetingStatus = 1 

    if attachments != '':
        appointment.Attachments.Add(attachments)

    recipients = filter(None, recipients)

    for recipient in recipients:
        appointment.Recipients.Add(recipient) 

    appointment.Save()

    # Only use .Display() if using tkinter
    appointment.Display()

要设置时区,您需要使用 TimeZones 界面,该界面代表 Microsoft Windows 识别的所有时区。它还使用 TimeZone 对象来设置或获取 StartTimeZone 属性 和 AppointmentItem 对象上的 EndTimeZone 属性。这是显示如何在 Outlook 约会中设置时区的示例 VB 代码:

Private Sub TimeZoneExample()
    Dim appt As Outlook.AppointmentItem = _
        CType(Application.CreateItem( _
        Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
    Dim tzs As Outlook.TimeZones = Application.TimeZones
    ' Obtain timezone using indexer and locale-independent key
    Dim tzEastern As Outlook.TimeZone = tzs("Eastern Standard Time")
    Dim tzPacific As Outlook.TimeZone = tzs("Pacific Standard Time")
    appt.Subject = "SEA - JFK Flight"
    appt.Start = DateTime.Parse("8/9/2006 8:00 AM")
    appt.StartTimeZone = tzPacific
    appt.End = DateTime.Parse("8/9/2006 5:30 PM")
    appt.EndTimeZone = tzEastern
    appt.Display(False)
End Sub

如果您已在 Outlook 配置文件中配置了 gmail 帐户,则可以使用 AppointmentItem.SendUsingAccount 属性.

这里是VB示例,展示了如何在 Outlook 中设置 SendUsingAccount 属性:

Sub SendUsingAccount() 
 Dim oAccount As Outlook.account 
 For Each oAccount In Application.Session.Accounts 
   If oAccount.AccountType = olPop3 Then 
     Dim oMail As Outlook.MailItem 
     Set oMail = Application.CreateItem(olMailItem) 
     oMail.Subject = "Sent using POP3 Account" 
     oMail.Recipients.Add ("someone@example.com")  
     oMail.Recipients.ResolveAll  
     Set oMail.SendUsingAccount = oAccount  
     oMail.Send  
   End If  
 Next  
End Sub