C
Chintan_K
Guest
Can someone tell me how to send google calendar invites to different users? I tried a lot but did not get any solution. I don't want to use iCalendar. I want to use only google calendar. The solution that I have, display events that are in my calendar. That's not what I want. I want to send invites at different emails.
Here is the code that I have:
class
Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-dotnet-quickstart.json
staticstring[] Scopes = { CalendarService.Scope.CalendarReadonly };
staticstringApplicationName = "Thursday Evening";
staticvoidMain(string[] args)
{
UserCredential credential;
using(varstream =
newFileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
stringcredPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath,
".credentials/calendar-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
newFileDataStore(credPath, true)).Result;
Console.WriteLine(
"Credential file saved to: "+ credPath);
}
// Create Google Calendar API service.
varservice = newCalendarService(newBaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
EventsResource.ListRequest request = service.Events.List(
"primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted =
false;
request.SingleEvents =
true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
// List events.
Events events = request.Execute();
Console.WriteLine(
"Upcoming events:");
if(events.Items != null&& events.Items.Count > 0)
{
foreach(var eventItem inevents.Items)
{
stringwhen = eventItem.Start.DateTime.ToString();
if(String.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}
Console.WriteLine(
"{0} ({1})", eventItem.Summary, when);
}
}
else
{
Console.WriteLine(
"No upcoming events found.");
}
Console.Read();
}
I tried different examples but did not get the satisfied answer. I would really appreciate the help.
Thanks!!!
Continue reading...
Here is the code that I have:
class
Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-dotnet-quickstart.json
staticstring[] Scopes = { CalendarService.Scope.CalendarReadonly };
staticstringApplicationName = "Thursday Evening";
staticvoidMain(string[] args)
{
UserCredential credential;
using(varstream =
newFileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
stringcredPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath,
".credentials/calendar-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
newFileDataStore(credPath, true)).Result;
Console.WriteLine(
"Credential file saved to: "+ credPath);
}
// Create Google Calendar API service.
varservice = newCalendarService(newBaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
EventsResource.ListRequest request = service.Events.List(
"primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted =
false;
request.SingleEvents =
true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
// List events.
Events events = request.Execute();
Console.WriteLine(
"Upcoming events:");
if(events.Items != null&& events.Items.Count > 0)
{
foreach(var eventItem inevents.Items)
{
stringwhen = eventItem.Start.DateTime.ToString();
if(String.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}
Console.WriteLine(
"{0} ({1})", eventItem.Summary, when);
}
}
else
{
Console.WriteLine(
"No upcoming events found.");
}
Console.Read();
}
I tried different examples but did not get the satisfied answer. I would really appreciate the help.
Thanks!!!
Continue reading...