2017-02-21 116 views
0

爲什麼我無法在預約時區輸入預約時間?添加startTimeZone和endTimeZone

try 
{ 
    $Appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service); 
    $Appointment.Subject=$CalendarItem."Subject"; 
    $Appointment.Start=$calendarItem."StartDateTime"; 
    $Appointment.End=$calendarItem."EndDateTime"; 
    $Appointment.Resources.Add($CalendarItem."Resources"); 
    $Appointment.StartTimeZone="Tokyo Standard Time"; 
} 
catch 
{ 
    # If we fail to set any of the required fields, we will not write the appointment 
    $NoError=$false; 
} 

回答

0

以下是在創建ExchangeService對象後指定的方法。

try 
{ 
    $Appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service); 
    $Appointment.Subject=$CalendarItem."Subject"; 
    $Appointment.Start=$calendarItem."StartDateTime"; 
    $Appointment.End=$calendarItem."EndDateTime"; 
    $Appointment.Resources.Add($CalendarItem."Resources"); 
    $Appointment.StartTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Tokyo Standard Time"); 
} 
catch 
{ 
    # If we fail to set any of the required fields, we will not write the appointment 
    $NoError=$false; 
} 

MSDN page

指定非本地時區,當您實例將被用於創建日曆項, 的 ExchangeService對象,並沒有設置StartTimeZone財產在 EndTimeZone財產的日曆項

OR

在日曆項目上設置StartTimeZone屬性和EndTimeZone屬性。

+0

嗨,感謝您的回覆。我仍然無法加入預約。我正在使用O365。 – Jay

+0

我認爲你正在保存約會? '$ Appointment.Save()' – TechSpud

+0

是的。如果沒有錯誤,則執行該命令。 $ Appointment.Save([Microsoft.Exchange.WebServices.Data.WellKnownFolderName] ::日曆); – Jay