Get distribution list from Outlook via JavaScript Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Get distribution list from Outlook via JavaScript without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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.

Answer

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);
}
We are here to answer your question about Get distribution list from Outlook via JavaScript - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji