EWS: Distribution list issue RRS feed

  • Question

  • Hi Guys,

    I have some code that is trying to get properties from journal items in exchange 2007. For this I am using EWS. Part of this project requires me to be able to break up a distribution list into all its recipients. This works fine on our testing server, but on our clients it can be problematic. Sometimes it throws an exception, other times it will just return a single recipient for a list that I know contains multiple recipients. Other times it works fine. 

    I have a few questions. 
    1. Is this something to do with the exchange configuration? if so what?
    2. Is there something wrong with my code? See below for snipped.
    3. Is there another way to do this? I have avoided breaking down the envelope journal for such information, I would far rather use EWS.

    Code snippet:

            //Email address is retrieved from original mail attached to envelope journal and passed to this function
            //RecipientType is relevant for the particular uses of this application
            private void StoreDistributionList(EWS.EmailAddressType address, int recipientType)
                    EWS.ExpandDLType group = new EWS.ExpandDLType();
                    group.Mailbox = address;

                    EWS.ExpandDLResponseType response = esb.ExpandDL(group);

                    if (response.ResponseMessages.Items[0].ResponseClass == MailMACRetrieval.EWS.ResponseClassType.Success)
                        foreach (EWS.EmailAddressType distAddress in ((EWS.ExpandDLResponseMessageType)response.ResponseMessages.Items[0]).DLExpansion.Mailbox)
                            //recurse each recipient in the off chance a distribution list has other distribution lists included.
                            StoreDistributionList(distAddress, recipientType);
                        DataRow recipientRow = mailDs.Tables["Recipients"].NewRow();
                        recipientRow["RecipientType"] = recipientType;
                        recipientRow["RecipientName"] = address.Name;
                        recipientRow["RecipientEmail"] = address.EmailAddress;
                catch (Exception err)
                    throw new Exception("Error occured trying to expand distribution list: " + err.ToString());

    Thursday, June 11, 2009 3:14 PM

All replies

  • Further to this, does anyone perhaps have a good method for extracting recipients from the envelope journal report? A standard method would be great. Ideally I do not want to have to parse the recipients, that can always be messy.
    Friday, June 12, 2009 11:35 AM