Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Outlook:传递用户名以获取AddressEntry_.net_Outlook - Fatal编程技术网

.net Outlook:传递用户名以获取AddressEntry

.net Outlook:传递用户名以获取AddressEntry,.net,outlook,.net,Outlook,在我的web应用程序中,我需要从exchange server获取用户的忙/闲信息 我可以使用下面的代码,然后使用GetFreeBusy方法获取我的帐户所需的信息 私有无效GetCurrentUserInfo { Outlook.AddressEntry addrEntry= Application.Session.CurrentUser.AddressEntry; 如果addrEntry.Type==EX { Outlook.ExchangeUser当前用户= Application.Sess

在我的web应用程序中,我需要从exchange server获取用户的忙/闲信息

我可以使用下面的代码,然后使用GetFreeBusy方法获取我的帐户所需的信息

私有无效GetCurrentUserInfo { Outlook.AddressEntry addrEntry= Application.Session.CurrentUser.AddressEntry; 如果addrEntry.Type==EX { Outlook.ExchangeUser当前用户= Application.Session.CurrentUser。 AddressEntry.GetExchangeUser; 如果currentUser!=null { StringBuilder sb=新的StringBuilder; 某人姓名: +currentUser.Name; sb.AppendLineSTMP地址: +currentUser.PrimarySmtpAddress; 某人的头衔: +currentUser.JobTitle; 某人,系: +当前用户部门; sb.地点: +currentUser.OfficeLocation; 某人的商务电话: +currentUser.BusinessTelephoneNumber; 某人移动电话: +currentUser.MobileTelephoneNumber; Debug.WriteLinesb.ToString; } } } 现在,我想从文本框或下拉列表中传递用户名,以获取用户的AddressEntry,但不确定使用哪种方法。请帮忙

谢谢, Navin

调用Application.CreateRecipient传递收件人的名称,后跟recipient.Resolve。然后可以使用Recipient.FreeBusy或Recipient.AddressEntry.GetFreeBusy

请记住,Outlook不能用于ma服务,例如IIS

在我的web应用程序中

Microsoft目前不建议也不支持从任何无人参与、非交互式客户端应用程序或组件(包括ASP、ASP.NET、DCOM和NT服务)自动化Microsoft Office应用程序,因为在该环境中运行Office时,Office可能会表现出不稳定的行为和/或死锁

如果您正在构建一个在服务器端上下文中运行的解决方案,那么您应该尝试使用安全的组件来无人值守地执行。或者,您应该尝试找到至少允许部分代码在客户端运行的替代方案。如果使用服务器端解决方案中的Office应用程序,该应用程序将缺少许多成功运行所需的功能。此外,您将面临整体解决方案稳定性方面的风险。你可以在这篇文章中了解更多

考虑改用EWS,有关更多信息,请参阅

正如Dmitry所说,您可以创建收件人,然后解析它

                var currentItem = (Office.Interop.Outlook.AppointmentItem)Globals.RoomAssistantAddIn.Application.ActiveInspector().CurrentItem;
                var oranizer = Globals.RoomAssistantAddIn.Application.Session.CreateRecipient(currentItem.Organizer);
                if (currentItem.Organizer != null && oranizer.Resolve())
                {
                    var user = oranizer.AddressEntry.GetExchangeUser();
                    ... // do what you want to do
                }