Asp.net在公共谷歌日历中创建活动

时间:2017-04-05 11:01:20

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

我需要在asp.net的公共日历中创建一个活动 我搜索了很多例子,但没有一个能帮我解决问题。 请查看以下代码,他没有错误,但不将事件添加到谷歌日历。任何帮助将不胜感激。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.Apis.Calendar;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Calendar.v3;
using Google.Apis.Services;

public partial class google : System.Web.UI.Page
{

    private object ddlCalendars;

    public IClientService Calendar_Service { get; private set; }

    protected void Page_Load(object sender, EventArgs e)
    {

        Event evnt = new Event();
        evnt.Summary = "Evento criado por programa";

        evnt.Location = "Coimbra";
        evnt.Description = "Este evento foi criado por programa";

        EventDateTime startTime = new EventDateTime() { DateTime = DateTime.ParseExact("05/04/2017 10:00:00", "dd/MM/yyyy HH:mm:ss", null) };// new EventDateTime();       
        EventDateTime endTime = new EventDateTime() { DateTime = DateTime.ParseExact("05/04/2017 11:00:00", "dd/MM/yyyy HH:mm:ss", null) }; // new EventDateTime();
        evnt.Start = startTime;
        evnt.End = endTime;

        EventAttendee ea = new EventAttendee();
        ea.DisplayName = "Mario";
        ea.Email = "myemail";
        ea.Organizer = false;
        ea.Resource = false;

        IList<EventAttendee> lstOfAtendee = new List<EventAttendee>();
        lstOfAtendee.Add(ea);
        evnt.Attendees = lstOfAtendee;

        EventsResource er = new EventsResource(Calendar_Service);
        er.Insert(evnt, ea.ToString());  

    }
}

0 个答案:

没有答案