giovedì 25 ottobre 2012

C# Google API - Delete Google Contact

The following code shows a c# method to delete a google contact.



        public void DeleteContact(ContactsRequest cr, Uri contactURL)
        {
            Contact contact = cr.Retrieve<Contact>(contactURL);

            try
            {
                cr.Delete(contact);
            }
            catch (GDataVersionConflictException e)
            {
                MessageBox.Show(e.Message);
            }
        }



The following code shows how to use the previous method.


            GDataCredentials Credentials = new GDataCredentials("yourMail@gmail.com", "yourPassword");
            RequestSettings settings = new RequestSettings("appName", Credentials);
            settings.UseSSL = true;

            ContactsRequest cr = new ContactsRequest(settings);
            Contact contatto = cr.Retrieve<Contact>(new Uri(("Contact URL"));

            DeleteContact(cr, new Uri("Contact URL"));




I want to remeber to go here http://support.google.com/mail/bin/answer.py?hl=it&answer=1173270 to get  Application-specific password

Nessun commento:

Posta un commento