Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

80
Visualizações
Get event ID of Google Calendar event after it has been created C#

I've written some code to add an event to Google Calander:

                    var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    new ClientSecrets
                    {
                        ClientId = "ID",
                        ClientSecret = "Secret",
                    },
                    new[] { CalendarService.Scope.Calendar },
                    Account.Text,
                    CancellationToken.None).Result;

                    var service = new CalendarService(new BaseClientService.Initializer
                    {
                        HttpClientInitializer = credential,
                        ApplicationName = "Custom CRM",
                    });
                    var myEvent = new Event
                    {
                        Summary = Title.Text,
                        Location = AppointmentLocation.Text,
                        ColorId = Convert.ToString(AppointmentColourInt),
                        Description = Description.Text,

                        Start = new EventDateTime()
                        {
                            DateTime = new DateTime(StartDate.Value.Year, StartDate.Value.Month, StartDate.Value.Day, Convert.ToInt32(StartTime.Text.Substring(0, 2)), Convert.ToInt32(StartTime.Text.Substring(StartTime.Text.Length - 2)), 00),
                            TimeZone = "Europe/London"
                        },
                        End = new EventDateTime()
                        {
                            DateTime = new DateTime(EndDate.Value.Year, EndDate.Value.Month, EndDate.Value.Day, Convert.ToInt32(EndTime.Text.Substring(0, 2)), Convert.ToInt32(EndTime.Text.Substring(EndTime.Text.Length - 2)), 00),
                            TimeZone = "Europe/London"
                        },
                    };

                    var recurringEvent = service.Events.Insert(myEvent, CalendarID);
                    recurringEvent.SendNotifications = true;
                    recurringEvent.Execute();

Is there a way I could get the ID of the event once it has been created so that I can save it to my database for future reference?

Thanks.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

var recurringEvent = service.Events.Insert(myEvent, CalendarID);
recurringEvent.SendNotifications = true;
var results = recurringEvent.Execute();

Execute will return to you the object it inserted. The Id should be in there.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda