简体   繁体   中英

Get distribution list from Outlook via JavaScript

In Outlook, I have 7 Groups where my email id. I need to get the group names (only name of the group not members of the group) where my email id. Group Names are: "Team A", "Team B" etc. Currently I can get group count.

var theMailItem = outLookApp.CreateItem(0);
//Count number of groups: which returns me 7
var test = theMailItem.Session.CurrentUser.AddressEntry.GetExchangeUser.GetMemberOfList.Count;
for (var i = 0; i < test; i++) {
   alert(test[i].Name);
}

Above code always return null. I want only 7 groups names like "Team A", "Team B" etc.

Firstly, all collections in OOM are 1 based, not 0.

Secondly, your "test" variable is an int, so test[i] makes no sense.

Thirdly, you can use a much simpler loop:

var dl = outLookApp.Session.CurrentUser.AddressEntry.GetExchangeUser().GetMemberOfList();
for (var i = 1 ; i < dl.count; i++)
{
   alert(dl.Item(i + 1).Name);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM