如何使用 EWS 从必需的与会者那里获取组详细信息
How to get group detail from Required Attendees using EWS
我正在尝试从与会者那里获取电子邮件地址的详细信息,因为群组中有更多地址,这是我的代码。
public List<Meeting> getAll(string email, string sDate, string eDate)
{
List<Meeting> res = new List<Meeting>();
ExchangeService es = new ExchangeService();
string username = Properties.Settings.Default.username;
string password = Properties.Settings.Default.password;
SecureString ssPassword = new SecureString();
foreach (char x in password)
ssPassword.AppendChar(x);
es.Credentials = new NetworkCredential(username, ssPassword);
es.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
FolderId folderID = new FolderId(WellKnownFolderName.Calendar, "xxxxxx@xxxx.com");
DateTime startDate = DateTime.ParseExact(sDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
DateTime endDate = DateTime.ParseExact(eDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
CalendarView cView = new CalendarView(startDate, endDate);
//cView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
FindItemsResults<Item> resultItem = es.FindItems(folderID, cView);
foreach (Item item in resultItem.Items)
{
ServiceResponseCollection<GetItemResponse> itemResponseCollection = es.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, new PropertySet(BasePropertySet.FirstClassProperties));
foreach (GetItemResponse itemResponse in itemResponseCollection)
{
Appointment app = (Appointment)itemResponse.Item;
res.Add(GetClassFromAppointment(app));
}
}
return res;
}
obj.Attendees = {aaa@xxxx.com, bbb@xxxx.com, Group@xxxx.com}
"Group@xxxx.com" 包含更多电子邮件地址:ccc@xxxx.com, ddd@xxxx.com
如何从群组中获取详细地址?
您应该即将使用 EWS ExpandGroup 操作 https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-expand-distribution-groups-by-using-ews-in-exchange-2013。例如,您的代码类似于
// Return the expanded group.
ExpandGroupResults myGroupMembers = es.ExpandGroup("Group@xxxx.com");
// Display the group members.
foreach (EmailAddress address in myGroupMembers.Members)
{
Console.WriteLine("Email Address: {0}", address);
}
另一种方法是因为您使用 Office365 是您可以使用 Microsoft Graph API https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http
获取群组成员
我正在尝试从与会者那里获取电子邮件地址的详细信息,因为群组中有更多地址,这是我的代码。
public List<Meeting> getAll(string email, string sDate, string eDate)
{
List<Meeting> res = new List<Meeting>();
ExchangeService es = new ExchangeService();
string username = Properties.Settings.Default.username;
string password = Properties.Settings.Default.password;
SecureString ssPassword = new SecureString();
foreach (char x in password)
ssPassword.AppendChar(x);
es.Credentials = new NetworkCredential(username, ssPassword);
es.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
FolderId folderID = new FolderId(WellKnownFolderName.Calendar, "xxxxxx@xxxx.com");
DateTime startDate = DateTime.ParseExact(sDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
DateTime endDate = DateTime.ParseExact(eDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
CalendarView cView = new CalendarView(startDate, endDate);
//cView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
FindItemsResults<Item> resultItem = es.FindItems(folderID, cView);
foreach (Item item in resultItem.Items)
{
ServiceResponseCollection<GetItemResponse> itemResponseCollection = es.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, new PropertySet(BasePropertySet.FirstClassProperties));
foreach (GetItemResponse itemResponse in itemResponseCollection)
{
Appointment app = (Appointment)itemResponse.Item;
res.Add(GetClassFromAppointment(app));
}
}
return res;
}
obj.Attendees = {aaa@xxxx.com, bbb@xxxx.com, Group@xxxx.com}
"Group@xxxx.com" 包含更多电子邮件地址:ccc@xxxx.com, ddd@xxxx.com
如何从群组中获取详细地址?
您应该即将使用 EWS ExpandGroup 操作 https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-expand-distribution-groups-by-using-ews-in-exchange-2013。例如,您的代码类似于
// Return the expanded group.
ExpandGroupResults myGroupMembers = es.ExpandGroup("Group@xxxx.com");
// Display the group members.
foreach (EmailAddress address in myGroupMembers.Members)
{
Console.WriteLine("Email Address: {0}", address);
}
另一种方法是因为您使用 Office365 是您可以使用 Microsoft Graph API https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http
获取群组成员