Not getting appointment subject using exchange service C# - c#

I have Full Access for Room mailbox ("conf1#xyz.com"). So i can retrieve all meetings scheduled in Room. In retrieve appointments I'm getting Subject as organizer Name instead of appointment subject.
For Example:
While Creating Appointment given data
Meeting Subject: Test1
Meeting Organizer: Suneel#xyz.com
Attendees: x#xyz.com
Location: conf1#xyz.com
While fetching data from Room getting subject as "Suneel" instead of "Test1"
Can anyone help me on this?
CalendarView cView1 = new CalendarView(fromDate, toDate);
FolderId foldertest = new FolderId(WellKnownFolderName.Calendar, new Mailbox("conf1#xyz.com"));
FindItemsResults<Appointment> findResults =
service.FindAppointments(foldertest, cView1);
findResults.Items.ToList().ForEach(d =>
{
Appointment appointment = Appointment.Bind(service, new
ItemId(d.Id.UniqueId));
roomAppointments.Add(appointment);
});

What your seeing is normal depending on the configuration of the Meeting room eg for privacy reasons you don't want the subject of every Meeting visible to all users that have access to the Meeting room. You can change this configuration using Set-CalendarProcessing https://technet.microsoft.com/en-us/library/dd335046(v=exchg.160).aspx and use the -AddOrganizerToSubject switch

Related

Can't limit access to shared calendar through impersonation using EWS

We're using EWS to integrate our CRM with Exchange Online 2010SP2. One of the tasks: provide one calendar for Sales persons with the next rule: every Sales can see all appointments in Scheduler, but can open and see details (body) only his/her own appointment. Appointment are being placed by CRM in response of certain business events. We tried to use impersonate and Sensitivity.Private property. Appointment is being placed with impersonated user name, but it can't be opened by that user neither through OWA nor via Outlook. So it's placed as private appointment of 'master' user (user who created shared calendar and his credentials is used for service connection), he can open it in Outlook or OWA. EWSEditor shows appointment's LastModifiedUser - correct impersonated username (not master's). In Fiddler we can see 'success' Response on appointment placement request (under impersonated user). In OutlookSpy, we can see that appointments PR_SENDER_NAME_W, PR_SENT_REPRESENTING_NAME_W properties shows 'master's' username. We stuck.
Impersonated user has 'owner' rights upon that shared calendar.
If Impersonating doesn't resolve this issue, can Delegate technique do that?
Thanks in advance for any help.
static void Main(string[] args)
{
ExchangeService services = new
ExchangeService(ExchangeVersion.Exchange2010_SP2);
services.Credentials = new WebCredentials("master#exchserver.com",
"MasterPwd");
services.Url = new Uri("https://someserver.com/ews/exchange.asmx");
FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Calendar);
FolderView fvFolderView = new FolderView(100);
DateTime startDate = DateTime.Now.AddDays(1);
DateTime endDate;
string SalesCalendarId = "AAMkADVlMGVjZWVkLT....AADo8XAAA=";
CalendarFolder folder = CalendarFolder.Bind(services, new
FolderId(SalesCalendarId));
TimeSpan ts = new TimeSpan(10, 00, 0);
startDate = startDate.Date + ts;
endDate = startDate.AddMinutes(60);
services.HttpHeaders.Add("X-AnchorMailbox","impersonateduser#exchserver.com");
appointment.Subject = "from Test";
appointment.Body = "Test";
appointment.Start = startDate;
appointment.End = appointment.Start.AddMinutes(30);
appointment.ReminderDueBy = appointment.Start.AddHours(1);
appointment.Sensitivity = Sensitivity.Private;
ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "impersonateduser#exchserver.com");
appointment.Save(SalesCalendarId, SendInvitationsMode.SendToNone);
}
You could use impersonated user to obtain ‘owner’ permissions.
Please include the code below before services.Credentials = new WebCredentials("master#exchserver.com", "MasterPwd")
services.PreAuthenticate = true;
you need to make sure that we have required permissions for EWS Impersonation as per the article mentioned below:
Configuring Exchange Impersonation in Exchange 2010
Using Exchange Impersonation in Exchange 2010
You could reference the following link:
Get all calendar events for a specific user

Not able to delete meeting using exchange web services having full access for Room

We have a problem deleting Appointments from Exchange using EWS.
I have Full Access for Room, which I'm able to cancel through outlook but not from our application.
Fetching Calendar Items:
Collection appointments = new Collection();
if (service != null)
{
CalendarView calView = new CalendarView(fromDate, toDate);
FindItemsResults<Item> masterResults = service.FindItems(WellKnownFolderName.Calendar, calView);
masterResults.Items.ToList().ForEach(c =>
{
Appointment appointment = c as Appointment;
appointment = Appointment.Bind(service, new ItemId(c.Id.UniqueId));
appointments.Add(appointment);
});
}
We select one appointment from above list and try to cancel that facing exception.
Cancel Appointment Code:
Appointment appointment = Appointment.Bind(service, new ItemId(uniqueId));
var cancelresult = appointment.CancelMeeting("The metting cancelled.");
we get an exception with the message "User must be an organizer for CancelCalendarItem action." This makes me really confused, because when I inspect the deletedAppointment object my email address is set as the organizer.
I have full access for room and able to cancel meeting from Outlook.
Can anyone help on this?
If you want to cancel an appointment then you need to access the Calendar of the organiser, find that appointment and cancel that appointment. You can't use the copy of the appointment in the Room mailbox as its a different object and also it won't contain all the potential attendees that should get the cancellation message.

Getting Master Occurrence for Private Appointments

I'm having trouble finding out how to get the master occurrence for a series of private appointments using the Exchange Web Service Managed API for C#.
When I retrieve the list of appointments using FindAppointments on the ExchangeService, I manage to get the occurrences within the search criteria. However, when I then try to get the recurring master appointment using Appointment.BindToRecurringMaster where the id is the id of the private occurrence, I get the error "The specified object was not found in the store., Item not found."
Is there any other way for me to retrieve the master occurrence for a private occurrence?
In my example below, I'm authenticating using a service account which as the Reviewer permissions on the target mailbox calendar.
var exchangeService = new ExchangeService();
exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
exchangeService.Credentials = new WebCredentials("service.user#organization.com", "password", "domain");
const string email = "other.user#organization.com";
// The following successfully retrieve all appointments including the private occurrence.
var appointments = exchangeService.FindAppointments(
new FolderId(WellKnownFolderName.Calendar, new Mailbox(email)),
new CalendarView(DateTime.UtcNow, DateTime.UtcNow.AddDays(1)));
const string id = "AAMkA..."; // Id of the private occurrence.
// The following fails saying "The specified object was not found in the store., Item not found."
var appointment = Appointment.BindToRecurringMaster(exchangeService, id);
Any help is appreciated.
What your describing is the expected behaviour for private Items if you haven't been delegated access to view private Items via the Delegate Operation. So you would need to either give the Service Account Delegate rights on the Mailbox using the Delegate operations https://msdn.microsoft.com/en-us/library/office/dn641959(v=exchg.150).aspx and set ViewPrivateItems to true. Or give the Service Account FullAccess to the Mailbox or use EWS Impersonation.

Creating appointment on Exchange server calendar as other user without impersonation (EWS)

I am creating simple app for appointments scheduling and I want to implement ability for me to create appointments for my users.
I managed to create,update and delete my calendar on Exchange Server, and I somewhat managed to create appointments adding my colleagues as RequiredAttendees like so:
//service variable is being created using my credidentals
Appointment meeting = new Appointment(service);
meeting.Subject = "Some subject ";
meeting.Body = "Some body.";
meeting.Start = DateTime.Now;
meeting.End = meeting.Start.AddHours(4);
meeting.Location = "Some Location";
meeting.RequiredAttendees.Add("myCollegue#mail.com");
meeting.ReminderMinutesBeforeStart = 60;
meeting.Save(new FolderId(WellKnownFolderName.Calendar,
"myCollegue#mail.com"),
SendInvitationsMode.SendToAllAndSaveCopy);
But it is just setting him as required attendee. Next thing is I tried using impersonation, but I can't access hosting server to set myself as master and others to have to share calendar with me (due to permissions and stuff) so I had to scrape that as well. Also, he set me up to be his publishing author on his calendar.
Is there something I am missing, or can't seem to find on MSDN sites?
EDIT: I am able to create appointment in his calendar in outlok.
If anyone comes across same issues as I did in here please follow these steps:
Make sure that person for which you are creating appointment sets you up (on exchange server or in outlok as "Editing author" with all permissions.
After that you can create appointments for him (verify this by going to your outlok and creating some test appointments).
This code works for me:
Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "your.colleague#company.com"));
Appointment appointmentOther = new Appointment(service);
appointmentOther.Subject = "Test 2";
appointmentOther.Body = "Body text";
appointmentOther.Start = DateTime.Now;
appointmentOther.End = DateTime.Today.AddHours(16);
appointmentOther.Location = "My Office";
appointmentOther.IsReminderSet = true;
appointmentOther.ReminderMinutesBeforeStart = 30;
appointmentOther.Save(inboxFolder.Id,SendInvitationsMode.SendToNone);
Good luck :)

Create appointment with custom properties in EWS

I try to add a custom property to created appointments like this:
var newEvent = new Appointment(service)
{
Start = start,
End = end,
Subject = subject,
ReminderMinutesBeforeStart = 15
};
var extendendProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Address, "organizer",
MapiPropertyType.String);
newEvent.SetExtendedProperty(extendendProperty, organizer);
but problem is that when I try get this appointment from server, property ExtendedProperty is empty.
In addition I create new appointment and add 'room' as a required attendee, and when I try get this appointment, I don't get it from my calendar but from room calendar.
So, I want to add extend property to my appointment and invite 'room'. Next get all appointments of the room and here I want read this property. It is even possible?
I read this topic: EWS Create Appointment in exchange with extra custom properties and as I understand I'll must have access to ExtendendPropertyDefinition when I want read this property, and must known id of this appointment before. Now I download all appointments from outlook by this code:
var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(userName));
var calendar = CalendarFolder.Bind(service, folderId, new PropertySet());
return calendar.FindAppointments(new CalendarView(start, stop)).ToList();
EDIT
Thanks Glen Scales!
It almost works as I want, but one thing. I can read this additional property if I download my own appointments, but in that code I download appointments from room calendar.
As I suppose when creating new appointment and add room as required attendant, it create his own appointment and this additional property isn't copied.
So is any way to get this additional property from room appointment, when I add this property to my?
You need to first Create a property set, add the extended property you want to load to that property set. Then tell EWS you want that property returned when you execute the FindAppointment method see https://msdn.microsoft.com/en-us/library/office/dd633697(v=exchg.80).aspx eg in your example
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();

Categories