Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using Google API for read,write ,delete events in Google calendar,read and write operation is working,but delete event operation is not working, give me solution and my source are given below.
advance thanks
C#
private void Delete_Click(object sender, EventArgs e)
        {
            try
            {

      
               
                CalendarService oCalendarService = GAuthenticate();
                

                //Search for Event
                EventQuery oEventQuery = new EventQuery( new Uri("http://www.google.com/calendar/feeds/" + ((CalendarEntry)(GoogleCalendar.SelectedItem)).SelfUri.ToString().Substring(((CalendarEntry)(GoogleCalendar.SelectedItem)).SelfUri.ToString().LastIndexOf("/") + 1) + "/private/full").ToString ());
                oEventQuery.ExtraParameters = location.Text;

                Google.GData.Calendar.EventFeed oEventFeed = oCalendarService.Query(oEventQuery);

         
                //Delete Related Events
                foreach (EventEntry oEventEntry in oEventFeed.Entries)
                {

                    
                    oEventEntry.Delete();
                    break;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


        }
 private CalendarService GAuthenticate()
        {
            string sGoogleUserName = UserName.Text;
            string sGooglePassword = Password.Text;
            Uri oCalendarUri = new Uri(new Uri("http://www.google.com/calendar/feeds/" + ((CalendarEntry)(GoogleCalendar.SelectedItem)).SelfUri.ToString().Substring(((CalendarEntry)(GoogleCalendar.SelectedItem)).SelfUri.ToString().LastIndexOf("/") + 1) + "/private/full").ToString());

            //Initialize Calendar Service
            CalendarService oCalendarService = new CalendarService("CalendarSampleApp");
            oCalendarService.setUserCredentials(sGoogleUserName, sGooglePassword);

            //Use Proxy 
            GDataRequestFactory oRequestFactory = (GDataRequestFactory)oCalendarService.RequestFactory;
            WebProxy oWebProxy = new WebProxy(WebRequest.DefaultWebProxy.GetProxy(oCalendarUri));
            oWebProxy.Credentials = CredentialCache.DefaultCredentials;
            oWebProxy.UseDefaultCredentials = true;
            oRequestFactory.Proxy = oWebProxy;

            return oCalendarService;
        }
Posted
Updated 26-May-12 7:17am
v3
Comments
ledtech3 26-May-12 14:09pm    
Mabey this older Post will help.
http://www.codeproject.com/Articles/196548/Managing-Google-Calendar-Events-using-NET

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900