是否可以通过EWS获取TimeZone和用户的工作时间?
我能够为当前用户(初始化ExchangeService的帐户)提取TZ和工作时间
UserConfiguration usrConfig = UserConfiguration.Bind(service, "WorkHours", WellKnownFolderName.Calendar, UserConfigurationProperties.All);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(new MemoryStream(usrConfig.XmlData));
XmlNodeList nlList = xmlDoc.GetElementsByTagName("WorkHoursVersion1");
Console.WriteLine(nlList.Item(0).InnerXml);
string str = nlList.Item(0).InnerXml;
但我无法为其他用户提取相同的信息。
答案 0 :(得分:3)
我使用GetUserAvailability操作。
输入是一组用户。输出包含array of AttendeeAvailability,其中包含WorkingHours属性,该属性本身包含TimeZone:
GetUserAvailabilityResults uars = service.GetUserAvailability(
new AttendeeInfo[] { new AttendeeInfo(smtpAddressOfUser, MeetingAttendeeType.Required, true), ... },
new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)),
AvailabilityData.FreeBusy
);
答案 1 :(得分:0)
如果您有权访问其他相关邮箱,您需要做的就是使用FolderId类指定要访问的邮箱,然后使用UserConfiguration.Bind方法的FolderId重载,例如
FolderId CalendarFolderId = new FolderId(Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Calendar, "user@domain.onmicrosoft.com");
UserConfiguration usrConfig = UserConfiguration.Bind(service, "WorkHours", CalendarFolderId, UserConfigurationProperties.All);
干杯 格伦
答案 2 :(得分:0)
您可以让特定的用户帐户冒充其他用户帐户并访问其详细信息,而无需使用其用户名和密码。
string impName = @"impy";
string impPassword = @"password";
string impDomain = @"domain";
string impEmail = @"impy@domain.com";
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new NetworkCredential(impName, impPassword, impDomain);
service.AutodiscoverUrl(impEmail);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, @"user@domain.com");
然后,您应该可以使用UserConfiguration.Bind()
来完成您的目标。
更多参考资料: http://msdn.microsoft.com/en-us/library/dd633680(v=exchg.80).aspx