Как получить информацию о группе от Обязательных участников, используя EWS - PullRequest
0 голосов
/ 21 февраля 2020

Я пытаюсь получить подробную информацию об адресе электронной почты от участников из-за большего количества адресов в группе, это мой код.

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

Как получить подробные адреса из группы?

1 Ответ

0 голосов
/ 24 февраля 2020

Вы должны просто использовать операцию ExpandGroup EWS 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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...