Click here to Skip to main content
15,887,356 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have created a VSTO (Appointments) application targeting Outlook 2003. The thing is that I have no idea how to get hold of the email address of the recipients of the appointment. I am well aware that in Outlook 2007 VSTO, one can use the following piece of code to get hold of the email address, but this does not work in Outlook 2003:
C#
olRecipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress;

I wrote the following method that does get hold of the recipients email address, but it makes use of LDAP, this is a problem seeing that each client will require a username and password....
C#
public string LookupEmailAddress(string legacyExchangeDN)
{
    string emailAddress = String.Empty;
    DirectoryEntry de = new DirectoryEntry("LDAP://server.local", "username", "password");
    DirectorySearcher deSearch = new DirectorySearcher();
    deSearch.SearchRoot = de;
    deSearch.Filter = "(&(objectClass=user)(legacyExchangeDN=" + legacyExchangeDN + "))";
    deSearch.SearchScope = SearchScope.Subtree;
    try
    {
        SearchResult results = deSearch.FindOne();
        if (!(results == null))
        {
            de = new DirectoryEntry(results.Path, "username", "password", AuthenticationTypes.Secure);
            foreach (System.DirectoryServices.PropertyValueCollection o in de.Properties)
            {
                if (o.PropertyName == "mail")
                {
                    emailAddress = o.Value.ToString();
                }
            }
        }
    }
    catch (System.Exception)
    {
        return String.Empty;
    }
    return emailAddress;
}

Does anyone know how I can get hold of the email address of the recipients attending the appointment / meeting?

Many thanks in advance.
Kind regards,

[Corrected code formatting]
Posted
Updated 8-Mar-10 2:28am
v2

 
Share this answer
 
I am running into the same problem. I've found one solution

applicationObject.GetNamespace("MAPI").AddressLists["Global Address List"].AddressEntries["USER NAME"].Details(0);

applicationObject is the pointer to your Outlook Application, and "USER NAME" is pretty much the sender's user name. This does not solve my problem but hopefully it solves yours
 
Share this answer
 

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