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:
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....
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]