通过.net api在Google日历中设置提醒

时间:2014-11-12 21:25:57

标签: asp.net google-api google-calendar-api

我正在编写一个在Google日历中创建活动的asp.net网页。我想添加一个"通知"在活动开始前30分钟发送电子邮件的活动。 通过api读取,我看到有一个用于插入事件的属性,称为"提醒"这似乎是一回事。使用谷歌的api游乐场,我可以成功创建活动并指定提醒。 但是,使用.net api版本1.9.0.990我可以创建事件,但没有为它设置提醒。以下是我写的代码:

Shared Sub eventWithReminder(calendarIdentifier As String, startTime As DateTime, endTime As DateTime, eventTitle As String)
    Dim calendarID As String


    Dim calList As CalendarList = RoomReservations_RoomReservationsServiceAccount.calService.CalendarList.List().Execute
    For Each Calendar In calList.Items
        If Calendar.Id = calendarIdentifier Then
            calendarID = Calendar.Id
        End If
    Next

    Dim anotherNewEvent As New [Event]
    anotherNewEvent.Summary = eventTitle
    Dim edtStart As New EventDateTime
    edtStart.DateTime = startTime
    Dim edtEnd As New EventDateTime
    edtEnd.DateTime = endTime
    anotherNewEvent.Start = edtStart
    anotherNewEvent.End = edtEnd

    Dim reminder As New EventReminder
    reminder.Method = "email"
    reminder.Minutes = 30
    Dim reminderList As New List(Of EventReminder)
    reminderList.Add(reminder)
    Dim remindData As New [Event].RemindersData
    remindData.UseDefault = False
    remindData.Overrides = reminderList
    anotherNewEvent.Reminders = remindData

    System.Net.ServicePointManager.Expect100Continue = False

    RoomReservations_RoomReservationsServiceAccount.calService.Events.Insert(anotherNewEvent, calendarID).Execute()

End Sub

然后我在Google日历网络界面中查看该事件,但通知部分显示"没有设置通知"

这个功能还没有内置到api中吗? 如果是,我是否错误地使用它?

1 个答案:

答案 0 :(得分:0)

提醒与经过身份验证的用户绑定。在这种情况下,Bob使用服务帐户创建事件,但是在用户的日历上。服务帐户无权修改用户的提醒。

为了更改某人的提醒,您需要以该人身份进行身份验证(使用他们的Oauth令牌)。

相关问题