Can't find sendNotifications option Google Calendar api v3 .NET - c#

I'm testing out the Google Calendar API v3 on .Net. I've managed to add an event to a calendar as follows:
Google.Apis.Calendar.v3.Data.EventAttendee attendee = new Google.Apis.Calendar.v3.Data.EventAttendee();
attendee.Email = "[email]#gmail.com";
List<Google.Apis.Calendar.v3.Data.EventAttendee> event_attendees = new List<Google.Apis.Calendar.v3.Data.EventAttendee>();
event_attendees.Add(attendee);
Google.Apis.Calendar.v3.Data.Event new_event = new Google.Apis.Calendar.v3.Data.Event();
new_event.Summary = "GoogleCalendarTest: Testing Event 4";
new_event.Description = "Testing .Net Google Calendar API";
new_event.Location = "Offices";
new_event.Start = new Google.Apis.Calendar.v3.Data.EventDateTime();
new_event.Start.DateTime = DateTime.Now;
new_event.End = new Google.Apis.Calendar.v3.Data.EventDateTime();
new_event.End.DateTime = new DateTime(2014, 12, 15, 12, 0, 0);
new_event.Attendees = event_attendees;
service.Events.Insert(new_event, "[email]#gmail.com").Execute();
I thought this would automatically send an invite email to the attendee but it seems that by default it is not sent as seen here in the documentation. The sendNotifications parameter is added is an optional parameter, this question shows how it's done on PHP but I can't figure how to add this on .Net.
UPDATE
Figured out a way to set sendNotifications on .Net:
Google.Apis.Calendar.v3.EventsResource.InsertRequest insert_event = new EventsResource.InsertRequest(service, new_event, "[email]#gmail.com");
insert_event.SendNotifications = true;
insert_event.Execute();
Still not sending an invitation email though, might still be doing something wrong.
UPDATE 2
Version issue?
I've found this question: Google Calendar API for .Net: Email notifications not sent when creating calendar event, which is very similar to the problem I have. Uninstalling and installing the API solved the problem...I tried this out but still have the same problem, currrent version: 1.9.0

This worked for me:
EventsResource.InsertRequest request = service.Events.Insert(newEvent, "primary");
request.SendNotifications = true;
Event createdEvent = request.Execute();

Related

Set Online meeting in Teams

I have been using Exchange WebServices (EWS) for some time now, in Asp.net C #, to add events in the calendars of Office365 users at my work.
I now needed those same events to appear at Microsoft Teams, with the possibility of going on videoconference.
Events appear but that possibility is not present.
One of the properties of "appointments" is "isOnlineMeeting". I tried to add it, making it true, but it always returns an error saying "Set action is invalid for property.".
In the online searches I have done, I have found that this is a read-only property.
So, is there any chance that I can "force" this property?
I have already configured my Exchange so that, in Outlook online when we do a new event, this is always by videoconference.
Some help?
Thank you!
UPDATE:
By the way, the code that I'm using is:
try {
ExchangeService service = new ExchangeService (ExchangeVersion.Exchange2013_SP1, TimeZoneInfo.FindSystemTimeZoneById ("GMT Standard Time"));
service.Url = new Uri ("https://outlook.office365.com/EWS/Exchange.asmx");
string User = "a#a.net";
string Password = "AAA";
service.Credentials = new NetworkCredential (User, Password);
Appointment appointment = new Appointment (service);
appointment.Subject = "Experiment";
appointment.Location = "Videoconference";
string dataStart = "10-02-2021 19:00:00.000";
string dataEnd = "10-02-2021 20:00:00.000";
appointment.Start = DateTime.Parse (dataStart);
appointment.End = DateTime.Parse (dataEnd);
appointment.Body = "<strong>Ignore! Just a test</strong>";
appointment.IsOnlineMeeting = true;
appointment.RequiredAttendees.Add ("b#a.net");
appointment.Save (SendInvitationsMode.SendOnlyToAll);
} catch (Exception ex) {
}
Posting the Answer for better knowledge
Copying from comments
Could you please try with this document by using Graph API. By using Graph API we can set "isOnlineMeeting" property to true, and "onlineMeetingProvider" property to "teamsForBusiness".

Amazon SMS for single number from c# sdk without creating topic

As per the docs, to send an SMS for single number, we need not create SNS topic.
Clearly, they have given a sample code which shows we can set phone number for publish request method
http://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html
As per the java docs, I can clearly see that method.
http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/sns/model/PublishRequest.html#setPhoneNumber-java.lang.String-
But, how do we implement same in c#? I couldn't find any method to send an sms without creating an SNS topic.
Can someone guide me how do I send an SMS without creating an SNS topic from C# SDK?
I hope this helps:
var smsAttributes = new Dictionary<string, MessageAttributeValue>();
MessageAttributeValue senderID = new MessageAttributeValue();
senderID.DataType = "String";
senderID.StringValue = "mySenderId";
MessageAttributeValue sMSType = new MessageAttributeValue();
sMSType.DataType = "String";
sMSType.StringValue = "Promotional";
////MessageAttributeValue maxPrice = new MessageAttributeValue();
////maxPrice.DataType = "Number";
////maxPrice.StringValue = "0.1";
CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
smsAttributes.Add("AWS.SNS.SMS.SenderID", senderID);
smsAttributes.Add("AWS.SNS.SMS.SMSType", sMSType);
////smsAttributes.Add("AWS.SNS.SMS.MaxPrice", maxPrice);
PublishRequest publishRequest = new PublishRequest();
publishRequest.Message = vm.Message;
publishRequest.MessageAttributes = smsAttributes;
publishRequest.PhoneNumber = vm.PhoneNumber;
AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient(vm.AccessKey, vm.SecretKey, config);
AmazonSNSResponse resp = new AmazonSNSResponse();
await client.PublishAsync(publishRequest);
AmazonSNSResponse response = new AmazonSNSResponse();
response.Status = HttpStatusCode.OK.ToString();
response.Message = "Success";
return response;
I believe you'll find the answer here: https://forums.aws.amazon.com/thread.jspa?threadID=250183&tstart=0
Basically what is saying and quote: "...PhoneNumber property was added in version 3.1.1.0 of AWSSDK.SimpleNotificationService..."
I haven't put example code since the PhoneNumber property is what is missing in the request, the rest should work as similar to Java Example :D.
See Publish(PublishRequest).
Amazon.SimpleNotificationService.Model.PublishRequest has a PhoneNumber property, used for setting the number when sending a direct SMS message.

Can't send Notifications using C# Facebook SDK

I am trying to send a notification (not app requests) to registered users, server-side using the C# Facebook SDK. I actually get a success message, but no notification is sent. Our app is not in sandbox and has canvas enabled. The code below show attempts to send both notifications and app requests--the notifications do nothing, but the app request works:
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = "MY_APP_KEY",
client_secret = "MY_SECRET",
grant_type = "client_credentials"
});
fb.AccessToken = result.access_token;
dynamic nparams = new ExpandoObject();
nparams.template = "Hello from my app!";
nparams.href = "Home";
dynamic requestParams = new ExpandoObject();
requestParams.message = "Hi there";
requestParams.title = "Please use this awesome app";
foreach (string facebookID in facebookIDs)
{
// This returns success:true, but doesn't actually do anything
var postResult = fb.Post(facebookID + "/notifications", nparams);
// This works and shows a request in the app center
var postResult2 = fb.Post(facebookID + "/apprequests", requestParams);
}
The fact that apprequests send here tells me the access token is ok, so why don't notifications work? We really need to do this server-side--has anyone been able to do that?
Got a response from facebook on this . . . basically, that this feature is in beta and it may just not work, despite giving Success responses
Good snippet Anthony. Appears to be working consistently now. +1 for your attempt.
PS: In case anyone stumbles upon this code, "facebookID" is a numeric Id and can be derived using the following link http://findmyfacebookid.com/

Time difference issue when adding a Google Calendar Event using C#

I am using "Google.GData.Calendar" API to add Events to the Google Calendar using c#. But there is time difference between the events created in my DB and Google Calendar.
Following is the Code to add an Event to Google Calendar using the Google.GData API:
public static void AddEventToGoogle()
{
//string timezone = "US Mountain Standard Time";
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
try
{
GOAuthRequestFactory authFactory = new GOAuthRequestFactory("cl", "MyApp");
authFactory.ConsumerKey = ConfigurationManager.AppSettings["GConsumerKey"].ToString();
authFactory.ConsumerSecret = ConfigurationManager.AppSettings["GConsumerKeySecret"].ToString();
authFactory.Token = "xxxxxxxxxx";
authFactory.TokenSecret = "xxxxxx";
Google.GData.Calendar.CalendarService service = new Google.GData.Calendar.CalendarService(authFactory.ApplicationName);
service.RequestFactory = authFactory;
EventEntry entry = new EventEntry();
entry.Title.Text = "Test Google Event Create";
entry.Content.Content = "Test Google Event Create";
entry.Notifications = false;
When eventTime = new When();
eventTime.AllDay = false;
eventTime.StartTime = new DateTime(2013, 5, 9, 8, 0, 0);
eventTime.EndTime = new DateTime(2013, 5, 9, 11, 0, 0);
entry.Times.Add(eventTime);
// Send the request and receive the response:
EventEntry insertedEntry = service.Insert(postUri, entry);
if (insertedEntry != null && !string.IsNullOrEmpty(insertedEntry.EventId))
{
//Get the insertedEntry.EventId
}
}
catch (GDataRequestException gre)
{
HttpWebResponse response = (HttpWebResponse)gre.Response;
}
}
But with the above code there is a time difference with the event I intended to create and the entry in the Google Calendar. The TimeZone I have in my Google Calendar is "(GMT-07:00) Mountain Time - Arizona". This is happening when i change the TimeZones of my Google Calendar to CST, PST,...
Please suggest a workaround for this situation or where do I need to specify the TimeZone while adding an event to Google Calendar.
Updated my question with the complete method i used to add an event
The GData library uses v2 of the Google APIs. I think you will need to migrate your code to v3 in order to get proper support for time zones on events.
For example, see this page which shows an example of creating a recurring event. (Switch to the ".NET" tab".
Here are some resources that may help you:
Migration Guide
What's new in v3 (it doesn't mention time zones though)
Client libraries (see the ".NET" tab)
I did look through your code and the reference guide to the v2 GData library. I only see TimeZone properties on the CalendarEntry, EventFeed, and EventQuery classes. Since you're not using any of those, I don't think it is possible in v2.
UPDATE
It is possible in the v2 API. You can pass a time zone in the ICAL formatted <gd:recurrence> tag. Take a look at the note following the example in this documentation.
However, it doesn't appear that it is exposed as a property of the EventEntry class in the .Net GData client library. So my recommendation stands - use the v3 api and client library.

send event from asp.net to google calender in web application

I want to send events to my google calendar account from asp.net application
Have a look at Google API Calendar
http://code.google.com/intl/nl-NL/apis/calendar/
http://code.google.com/intl/nl-NL/apis/calendar/data/2.0/developers_guide_dotnet.html#CreatingSingle
Create single-occurance event
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = "Tennis with Beth";
entry.Content.Content = "Meet for a quick lesson.";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "South Tennis Courts";
entry.Locations.Add(eventLocation);
When eventTime = new When(DateTime.Now, DateTime.Now.AddHours(2));
entry.Times.Add(eventTime);
Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);
look at the API
Like Murph said in the comment, link to the guide for .Net API

Categories

Resources