View Single Post
  #1 (permalink)  
Old April 18th, 2010, 10:52 AM
sid sid is offline
Registered User
 
Join Date: Apr 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'System.Web.HttpApplicationState' does not contain a definition for 'Session'

Below is the code to obtain Members of an Exchange Distribution List.I am using this as namespace Outlook = Microsoft.Office.Interop.Outlook;to get members from Outlook.

private void GetDistributionListMembers()
{

//using app = (HttpContext.Current.ApplicationInstance);

//if (app != null)

//{
Outlook.SelectNamesDialog snd = Application.Session.GetSelectNamesDialog();
Outlook.AddressLists addrLists = Application.Session.AddressLists;

foreach (Outlook.AddressList addrList in addrLists)
{
if (addrList.Name == "All Groups")
{
snd.InitialAddressList = addrList;
break;
}
}
snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo;
snd.ToLabel = "D/L";
snd.ShowOnlyInitialAddressList = true;
snd.AllowMultipleSelection = false;
snd.Display();
if (snd.Recipients.Count > 0)
{
Outlook.AddressEntry addrEntry = snd.Recipients[1].AddressEntry;
if (addrEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeDistribut ionListAddressEntry)
{
Outlook.ExchangeDistributionList exchDL = addrEntry.GetExchangeDistributionList();
Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers();
if (addrEntries != null)
foreach (Outlook.AddressEntry exchDLMember
in addrEntries)
{
//Debug.WriteLine(exchDLMember.Name);
Response.Write(exchDLMember.Name);
}
}
}
//}
}

This is the error which I am getting:
'System.Web.HttpApplicationState' does not contain a definition for 'Session' and no extension method 'Session' accepting a first argument of type 'System.Web.HttpApplicationState' could be found (are you missing a using directive or an assembly reference?)

Requirement is to get all members of Outlook distribution list & mail them on submit of form button.

Urgent help needed