Calendar Events not working properly using Ms Graph API? - xamarin

I am working on Outlook Calendar Events integration using Microsoft Graph Api in Xamarin forms. Also, i have done with the Authentication part
but i have some queries related to fetching of Calendar Events.
Q. I am able to fetch Calendar Events through my code , but its limited to "10" events only. I am not able to fetch all my outlook calendar events.
Client = new GraphServiceClient("https://graph.microsoft.com/v1.0/",
new DelegateAuthenticationProvider(async (requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", authResult.AccessToken);
}));
var events = await Client.Me.Calendar.Events.Request().GetAsync();
var appointmentList = events.ToList();
foreach (var appointment in appointmentList)
{
Random randomTime = new Random();
Meetings.Add(new Model.Meeting()
{
From = Convert.ToDateTime(appointment.Start.DateTime).ToLocalTime(),
To = Convert.ToDateTime(appointment.End.DateTime).ToLocalTime(),
EventName = appointment.Subject,
Color = colorCollection[randomTime.Next(9)]
});
}
Can anyone help me out to fetch all the calendar events??
Thanks.

Related

Create a group chat using proactive message bot framework

I'm working on a adaptive card and having a button on card which is a choice card as show card, on click of submit of that choice card i want to start a group chat with the select users.
I'm trying to do it using proactive message for group chat but didnt got any internet ref for the code using c#.
Can anyone suggest some ref for that.
var conversationParameters = new ConversationParameters
{
IsGroup = true,
Members = new ChannelAccount[] { channelAccount1, channelAccount2, activity.Recipient, activity.From },
Activity = (Activity)message
};
var identity = new MicrosoftAppCredentials(MicrosoftAppId, MicrosoftAppPassword);
MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl);
var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl), identity);
ConversationResourceResponse CreateConversationResponse = await connectorClient.Conversations.CreateConversationAsync(conversationParameters);
I'm getting bad request error

Is it possible to programmatic-ally access the list of contacts in outlook using Office Add In

I am building an Add In which is supposed to grab in addition to the list of contacts an account has, the contacts (to, from, cc and bcc) that are used in the current Item (Message).
As per the documentation, the following instruction gave me zero contacts, although I have contacts in the contacts book, and reading a message with a sender email.
var contacts = Office.context.mailbox.item.getEntities().contacts;
I need to grab the list of contacts I manage in my account:
This list is accessible with the open graph APIs, I wonder if it's also accessible locally with the Office object for Office Add-Ins
Office Js does not provide APIs to get the list of contacts in the account.
But you can get an auth token from Outlook using authentication APIs, then use this token to acquire Graph token to interact with Graph APIs and get the list of contacts
Office.context.auth.getAccessTokenAsync(function (result) {
if (result.status === "succeeded") {
// Use this token to call Web API
var ssoToken = result.value;
// Now send this token to your server and acquire a Graph token
// Server can talk to Graph APIs and get contacts to display
} else {
// Handle error
}
});
Create a Node.js Office Add-in that uses single sign-on
It looks you misunderstood the documentation.
A quote:
The following example accesses the contacts entities in the current item's body.
var contacts = Office.context.mailbox.item.getEntities().contacts;
You could get all contacts using the below link:
Microsoft.Office.Interop.Outlook.Items OutlookItems;
Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();
MAPIFolder Folder_Contacts;
Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
OutlookItems = Folder_Contacts.Items;
MessageBox.Show("Wykryto kontaktów: " + OutlookItems.Count.ToString());
for (int i = 0; i < OutlookItems.Count; i++)
{
Microsoft.Office.Interop.Outlook.ContactItem contact = (Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i+1];
sNazwa = contact.FullName;
sFirma = contact.CompanyName;
sAdress = contact.BusinessAddressStreet;
sMiejscowosc = contact.BusinessAddressPostalCode + " " + contact.BusinessAddressCity;
sEmail = contact.Email1Address;
dataGridView1.Rows.Add(sNazwa, sFirma, sAdress, sMiejscowosc, sEmail);
}
For more information, please refer to the below link:
Get Outlook contacts into C# form-based application

EWS - Share extended properties with invited attendees

Is it possible to share extended properties with invited attendees of an Exchange appointment? In other words, is it possible to create a meeting in Exchange using EWS which would pass it's extended properties (custom fields) to attendee's copies of the meeting (assuming they use Exchange as well)?
So far non of the options I tried worked - I can only see the properties in the organizer's meeting through both EWS and Outlook.
A peace of working example or explanation of solution would be great.
UPDATE. Based on this thread here's what I tried (and it didn't work):
var exchangeAppointment = new Appointment(exchange);
...
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "keyword", MapiPropertyType.String);
exchangeAppointment.SetExtendedProperty(extendedPropertyDefinition, "value");
var sendModeForSave = SendInvitationsMode.SendToAllAndSaveCopy;
await exchangeAppointment.Save(sendModeForSave);
foreach (var email in command.MeetingAttendeeEmails) {
exchangeAppointment.RequiredAttendees.Add(email);
}
var sendModeForUpdate = SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy;
await exchangeAppointment.Update(ConflictResolutionMode.AlwaysOverwrite, sendModeForUpdate);
You could create appointment with custom properties in EWS, then view custom extended properties by using the EWS Managed API 2.0
You could refer to this code:
PropertySet YourProperyset = new PropertySet(BasePropertySet.FirstClassProperties);
var extendendProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Address, "organizer",MapiPropertyType.String);
YourProperyset.Add(extendendProperty);
var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(userName));
var calendar = CalendarFolder.Bind(service, folderId);
var calendarView = new CalendarView(start, stop);
calendarView.PropertySet = YourProperyset;
return calendar.FindAppointments(calendarView).ToList();
For more information, you could refer to these link:
Create appointment with custom properties in EWS
Viewing custom extended properties by using the EWS Managed API 2.0
Set CustomProperties on appointment for all attendees

Facebook Conversion Tracking Pixel in Ajax Application

Running into a facebook tracking issue. When a user creates an account, I want to fire off the FB tracking pixel.
When the landing page went live, only 1/2 of the new users are tracked. Any ideas on where the leaking issue is?
pp.onNewUser = function(v,u) {
// Set Facebook Tracking
var fb_param = {};
fb_param.pixel_id = '43211230943123';
fb_param.value = '0.00';
fb_param.currency = 'USD';
var fpw = document.createElement('script');
fpw.async = true;
fpw.src = '//connect.facebook.net/en_US/fp.js';
var ref = document.getElementsByTagName('script')[0];
ref.parentNode.insertBefore(fpw, ref);
try {
console.log('Account Created...');
} catch(ex) {}
pp.aCN('step1a', 'hidden');
pp.rCN('step2b', 'hidden');
};
First I'd recommend upgrading to the new version of the code. There's a guide here:
Facebook: Migrate to the New Conversion Pixel
Or you can use the dropdown in adsmanager to generate it. There is also information on firing multiple events, for example: website custom audience and a conversion event.

Update events from recurring event of Google Calendar using C# API

I am using the C# Google API to add the Recurring Events programmatically from my application(asp.net mvc - C#). Following is the code for it( I am adding a Daily Event which starts on Dec 01, 2012 and ends at Dec 03, 2012):
GOAuthRequestFactory authFactory = new GOAuthRequestFactory("cl", "MyApp");
authFactory.ConsumerKey = "xxxx";
authFactory.ConsumerSecret = "yyyy";
authFactory.Token = "zzzz";
authFactory.TokenSecret = "ssss";
Google.GData.Calendar.CalendarService service = new Google.GData.Calendar.CalendarService(authFactory.ApplicationName);
service.RequestFactory = authFactory;
EventEntry entry = new EventEntry();
entry.Title.Text = "Year End Meeting";
Recurrence recur = new Recurrence();
recur.Value = "DTSTART;VALUE=DATE:20121201\r\nDTEND;VALUE=DATE:20121201\r\nRRULE:FREQ=DAILY;UNTIL=20121203;INTERVAL=1";
entry.Recurrence = recur;
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
EventEntry insertedEntry = service.Insert(postUri, entry);
if (insertedEntry != null && !string.IsNullOrEmpty(insertedEntry.EventId))
{
//Update the Google Event Id to the Event Table
this.UpdateGoogleEventId(_userId, _eventId, insertedEntry.EventId);
}
Until this everything goes fine. Now i need to update a particular Event(only this instance) from the Recurring Event. For Ex.; I need to change the Dec 02, 2012 Event's Title to "Plan for Next Year". Likewise, I need to do the same for All Following, All events in this series update actions also. I was doing a Delete of all Events based on the Google Event Id(which is in the response when creating the Recurring Event) and then again creating the Events, which is kind of double work.
This is how i delete all the Recurring Events and do the Create as given above:
Uri delteUri = new Uri("https://www.google.com/calendar/feeds/default/private/full/" + googleeventid);
EventQuery deleteQuery = new EventQuery(delteUri.ToString());
EventFeed deleteFeed = service.Query(deleteQuery);
if (deleteFeed.Entries.Count > 0)
{
AtomEntry eve = deleteFeed.Entries[0];
if (eve != null)
{
service.Delete(eve);
}
}
What is the best way to just update only the instance based on the required conditions(Only this instance, All following, All events in this series)?
Just figured this out 10 minutes ago.
To access a single instance of a recurring event on a certain date use the following as the event url:
https://www.google.com/calendar/feeds/default/private/full/"
+ googleEventId + "_" + dateTime.ToString("yyyyMMdd");

Resources