2012年2月21日 星期二

Create Google Calendar Event using Google Calendar API


Google api asp.net client download







public void CreateCalendarEvent(string content)
        {
            CalendarService calendarService = new CalendarService("CNBlogsMeeting");
            calendarService.setUserCredentials("Email", "Password");

            EventEntry entry = new EventEntry();

            //日曆標題與內容
            entry.Title.Text = content;
            entry.Content.Content = content;

            //開始與結束時間,17:00~18:00
            When eventTime = new When(DateTime.Now,
                DateTime.Now);
            entry.Times.Add(eventTime);

            //需要邀請的参會者
            //Who who = new Who();
            //who.Email = "cho88hk@gmail.com";
            //who.Rel = "http://www.yahoo.com.hk";
            //entry.Participants.Add(who);

            //给被邀請者發送通知
            //entry.Notifications = true;

            //被邀請者可以修改該日曆項
            //entry.ExtensionElements.Add(new GuestsCanModify("true"));

            Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
            AtomEntry insertEntry = calendarService.Insert(postUri, entry);

            //Assert.NotNull(insertEntry);
        }

沒有留言:

張貼留言