使用 EWS 托管 API 为其他用户创建约会?

发布于 2024-08-24 05:54:39 字数 511 浏览 4 评论 0原文

在 EWS 托管 API 中,可以轻松地为特定用户创建约会:

ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredentials ( "administrator", "password", "domain" );
service.AutodiscoverUrl(emailAddress);

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save();

这将为管理员创建约会。但是假设我实际上想为另一个用户创建一个约会(而不是将该用户添加为我的约会的与会者)。这可以通过 EWS 托管 API 实现吗?

In EWS Managed API is it easy to create an appointment for a specific user:

ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredentials ( "administrator", "password", "domain" );
service.AutodiscoverUrl(emailAddress);

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save();

This will create a appointment for the administrator. But say I wanted to actually create an appointment for another user (not add that user as an attendee to me appointment). It this possible via the EWS Managed API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云淡风轻 2024-08-31 05:54:39
Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "[email protected]"));

也会工作。
然后将 inboxFolder.id 传递给 Appointment.Save 调用。更新和删除不需要这个。
最好的答案是使用模拟,但这需要服务器管理员启用它。如果你没有这样的权力,这个方法可以让你做你需要做的事。
注意:运行应用程序的用户必须拥有目标帐户的权限,否则将会失败(理应如此)。

此处找到:http://msdn.microsoft.com/en-us/库/gg274408(v=EXCHG.80).aspx

Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "[email protected]"));

Will work too.
Then pass inboxFolder.id to the Appointment.Save call. The updates and deletes don't need this.
The best answer is to use impersonate, but this requires it to be enabled by the server admins. If you don't wield such power, this method will let you do what you need.
Note: the user running your application must have permissions on the target account or this will fail (as it should).

Found here: http://msdn.microsoft.com/en-us/library/gg274408(v=EXCHG.80).aspx

梦幻的心爱 2024-08-31 05:54:39

我知道这个问题已经得到解答,但为了回答@Aamir 的评论,您可以使用代表来完成此操作,我刚刚为我正在从事的项目完成了此操作。

正如 @matt 在他的回答中建议的那样,您可以修改约会的保存方法以指向其他用户文件夹,在本例中为日历。

代码如下所示

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save(new FolderId(WellKnownFolderName.Calendar, new Mailbox(_EmailAddress)));

希望有帮助

I know this has been answered but in answer to @Aamir's comment you can do this using delegates I've just done it for a project I'm working on.

As @matt suggested in his answer you can amend the save method of the appointment to point to the other users folder which in this case would be Calendar.

Code would look as below

Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save(new FolderId(WellKnownFolderName.Calendar, new Mailbox(_EmailAddress)));

Hope that helps

以可爱出名 2024-08-31 05:54:39

我从这篇文章中弄清楚了:
http://msdn.microsoft.com/en-us/ library/dd633680(EXCHG.80).aspx

您应该使用 service.ImpersonatedUserId 属性。

I figured it out from this article:
http://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx

You should use the service.ImpersonatedUserId attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文