Techniques for integrating an ASP.NET intranet app with the Outlook calendar

风格不统一 提交于 2019-12-04 04:59:56

We recently did same kind of integration for our intranet application using the Exchange Web Services Managed API. That would be one way of going about for the second option. I have never tried the same using JavaScript, so no idea on that.

With regards to the query for comment 1: You would need a single AD user whom you will be using to impersonate and work on the other users account. Please refer to the example below:

Lets say I have an Active Dir account named fabrikam\myappname with password Fabi$Gre@t2010

void CreateFolder(string targetUserEmail) {
    string appName = "myappname";
    string appPassword = "Fabi$Gre@t2010";
    string emailDomain = "fabrikam";
    string appEmail = string.Format("{0}@{1}.com", appName, emailDomain);

    ExchangeService service = new ExchangeService();
    service.Credentials = new NetworkCredential(appName, appPassword, emailDomain);
    service.AutodiscoverUrl(appEmail);

    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, targetUserEmail);

    Folder newFolder = new Folder(service);
    newFolder.DisplayName = "TestFolder1";

    newFolder.Save(WellKnownFolderName.Inbox);
}

Do check the article Configuring Exchange Impersonation to make Impersonation working.

Hope that helps.

If for some reason you don't want to enable impersonation (since it's global) you can also have each user share their calendar with your profile that is running the app (appName in CodeCanvas' sample). Once they give your the appropriate permission (read/write/edit) you can add appointments to their calendar like so:

myappointment = new Appointment(service);
myappointment.Subject = "subject";
myappointment.Body = "body";
myappointment.Start = myStartTime;
myappointment.End = myStartTime.AddHours(1);
myMailbox = new Mailbox("username@domain.com");
myFolder = new FolderId(WellKnownFolderName.Calendar, myMailbox);
myappointment.Save(myFolder, SendInvitationsMode.SendToNone);
/* get the appointment id so your app can access it later to update or delete */ 
myexchangeid = myappointment.Id.UniqueId;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!