Event Added Through API not visible in Google Calendar - google-api

We are adding an Event through the Calendar API
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example#example.com";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example#example.com").Execute();
When we try and view the Event in the users calendar it is not visible. However we can retrieve the Event directly by Id
EventsResource.GetRequest gr = new EventsResource.GetRequest(service, "example#example.com", "43ha9dpv15h5oj2jv853g4vljk");
gr.AlwaysIncludeEmail = true;
Event evv = gr.Execute();
When we remove the attendee entry for the Owner "example#example.com" the Event becomes visible in the Calendar
evv.Attendees.Remove(ea);
So what we are seeing is that when the Owner of the Event is an attendee then it is not visible in Their Google Calendar.
I have checked the ACL Rules and the following entry exists
ETag "\"00000000000000000000\""
Id "user:example.example.com"
Kind "calendar#aclRule"
Role "owner"

Thanks to #luc,
The issue here is that the user does indeed have in their Calendar settings the following setting = 'No, only show invitations to which I have responded'
In my example the EventAttendee is added but their ResponseStatus is 'actionNeeded' - hence it is not visible in the calendar despite the owner being the user.
If in my code, I set the ResponseStatus of the EventAttendee to 'accepted' then it becomes visible in the users calendar. Correct code needs to be:
Event ev = new Event();
ev.Summary = "ILINK TEST - IGNORE";
ev.Start = new EventDateTime();
ev.Start.DateTime = DateTime.Now.AddMonths(-3);
ev.End = new EventDateTime();
ev.End.DateTime = ev.Start.DateTime;
ev.Attendees = new List<EventAttendee>();
EventAttendee ea = new EventAttendee();
ea.Email = "example#example.com";
ea.ResponseStatus = "accepted";
ev.Attendees.Add(ea);
Event evv = service.Events.Insert(ev, "example#example.com").Execute();

Related

Outlook VSTO - Create Mail and save it in Inbox - Set Sender using Outlook Redemption

I basically want to create emails which shall be displayed in the Outlook Inbox using C# Outlook VSTO AddIn.
I have installed the test dlls for Outlook Redemption in my C# Outlook VSTO Addin.
For testing purposes I created a Ribbon Bar with a button. When the button is clicked the following event is triggered:
private void CreateMailItemWithRedemption()
{
//FYI: outlookApp is set in Ribbon load event
//Outlook.Application outlookApp = Globals.ThisAddIn.Application as Microsoft.Office.Interop.Outlook.Application;
var outlookNameSpace = outlookApp.GetNamespace("MAPI");
RDOSession session = new RDOSession();
session.MAPIOBJECT = outlookNameSpace.MAPIOBJECT;
RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);
RDOMail msg = folder.Items.Add("IPM.Note");
msg.Sent = true;
DateTime dt = new DateTime(2021, 8, 29, 5, 10, 20, DateTimeKind.Utc);
msg.ReceivedTime = dt;
msg.Subject = "Mail created with Redemption";
msg.To = “******#outlook.com”;
msg.Sender = GetAddressEntry("[TestFirstName] [TestLastName]");
msg.Save();
}
It basically works – but for the time being I am stuck with setting the Sender for the new RDOMail which I understand needs to be an RDOAddressEntry.
The GetAddressEntry method looks as follows (with firstname string + lastname string of an existing contact as parameter, like “John Do”):
private RDOAddressEntry GetAddressEntry(string _name)
{
RDOSession session = new RDOSession();
session.MAPIOBJECT = outlookApp.Session.MAPIOBJECT;
RDOAddressList contacts = session.AddressBook.GAL;
RDOAddressEntry contact = contacts.ResolveName(_name);
MessageBox.Show(contact.ToString());
return contact;
}
At contacts.ResolveName an exception is thrown. Do you have an idea what I am doing wrong?
Any hints are welcomed.
Many thanks in advance
Alexander

Calendar Events not working properly using Ms Graph API?

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.

Create mail in Exchange Online inbox programatically

Have been facing an issue since days about EWS. So my scenario is;
I was to programmatically sync GMAIL and EXCHANGE ONLINE. So here is what I have done;
Connect to Gmail using Gmail API
Fetch mail from gmail get the email body, to, from, attachment and
all other thing
connect to Exchange online using EWS 2.0
Now the problem is here, how can I create an email in Inbox which looks like incoming mail from the sender;
Here is the code I have done;
_service = new ExchangeService(ExchangeVersion.Exchange2013);
_service.TraceEnabled = true;
_service.Credentials = new WebCredentials("admin#xyz.onmicrosoft.com", "password");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
_service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "xyz#xyz.onmicrosoft.com");
EmailMessage message = new EmailMessage(_service);
Random r = new Random();
message.Subject = "Email Message";
message.From = new EmailAddress("xyz#gmail.com");
message.Sender = new EmailAddress("xyz#gmail.com");
message.Body = new MessageBody(BodyType.HTML, "<HTML><body><h1>This is a voice mail.</h1></BODY></HTML>");
message.ToRecipients.Add(new EmailAddress(""));
message.Save(WellKnownFolderName.Inbox);
This way its creating an email in inbox but it shows as a draft mail. I dont want it, I want it to look as RECEIVED mail.
Am I doing anything wrong?
You need to set a couple of properties before saving the message.
// Set a delivery time
ExtendedPropertyDefinition PidTagMessageDeliveryTime =
new ExtendedPropertyDefinition(0x0E06, MapiPropertyType.SystemTime);
DateTime deliveryTime = DateTime.Now; // Or whatever deliver time you want
message.SetExtendedProperty(PidTagMessageDeliveryTime, deliveryTime);
// Indicate that this email is not a draft. Otherwise, the email will appear as a
// draft to clients.
ExtendedPropertyDefinition PR_MESSAGE_FLAGS_msgflag_read = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);
message.SetExtendedProperty(PR_MESSAGE_FLAGS_msgflag_read, 1);
These properties aren't settable after the items is saved, so it's important to do it before the first Save call.

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");

Reminder Launch But can not open the Page in its URL

The reminder has been created with URl as below.
Problem :
To test the reminder, I have to close the app. When this reminder is launched on Home Screen which covers with a Wallpaper , the URL in the notification reminder dialogbox which ontop of the wallpaper can not be clicked or no action when press.
would appreciate help on this problem
Thanks
String strReminderNameId = System.Guid.NewGuid().ToString();
string queryString = "";
queryString = "?ReminderId=" + strReminderNameId;
Uri navigationUri = new Uri("/Testing.xaml" + queryString, UriKind.Relative);
RecurrenceInterval recurrence = RecurrenceInterval.None;
recurrence = RecurrenceInterval.Daily;
Reminder reminder = new Reminder(strReminderNameId);
reminder.Title = "Testing";
reminder.Content = "Testing 123";
reminder.BeginTime = beginTime;
reminder.ExpirationTime = expirationTime;
reminder.RecurrenceType = recurrence;
reminder.NavigationUri = navigationUri;
ScheduledActionService.Add(reminder);
It's a normal behavior. When some notification coming and screen is locked - phone is wake up and show you what's happed but you couldn't click on notification to perform provided action.

Resources