Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, my troubles are below.
1. I need to replace code "EWS" to "office365 Rest API" because The deadline is approacing.

In my source, "targetGroup" is address for Microsoft.Exchange.WebServices.Data.MailboxType.PublicGroup.
I tried to search a function which can get members in PublicGroup in office365 REST API, but I can't.
How do I replace ?(Now using v1.0 in otherplace)

2. How do I get userID from user address.My Apprication is Calendar.
First: find user in PublicGroup.
Second : get userID from user.
Third : get schedule using userID.
Last : show schedule for a day.

EWS is easy to get schedle. But I can't in office365 REST API.
// I want a userID
client.Users[userID].Calendar.Request().GetAsync();


What I have tried:

// 1's source.
    public class EWSHandler {
        public static List<UserDataInfo> GetUserData(string userAddress, string userPassword, string targetGroup) {
            var retval = new List<UserDataInfo>();
            try {
                // Return the expanded group.
                ExchangeService service = new ExchangeService {
                    Credentials = new WebCredentials(userAddress, userPassword)
                };

                service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
                var myGroupMembers = service.ExpandGroup(targetGroup);

                // Display the group members.
                foreach (EmailAddress address in myGroupMembers.Members) {
                    retval.Add(new UserDataInfo() { 
                        UserAddress = address.Address, 
                        UserName = address.Name, 
                        IsUser = (address.MailboxType == MailboxType.Mailbox ? true : false),
                    });
                }
            }
            catch (ServiceResponseException ex) {
            }
            catch (Exception ex) {
            }
            return retval;
        }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900