Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
| Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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
  #2 (permalink)  
Old April 18th, 2010, 12:36 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Looks like Application is referring to the standard ASP.NET Application object (of type HttpApplicationState). You probably need to prefix it with the namespace that contains the Application class you're trying to use.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old April 18th, 2010, 11:44 PM
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'

Hi Imar,

Below are the namespaces I am using

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using AbsenceTrackingSystem;
using Outlook = Microsoft.Office.Interop.Outlook;


I tried as below in the code:

AbsenceTrackingSystem app = (HttpContext.Current.ApplicationInstance);

Its telling AbsenceTrackingSystem is a namespace & used as a type.

could you help me by writing that piece of code in the namespace or in the code below:

private void GetDistributionListMembers()
{

AbsenceTrackingSystem 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);
}
}
}
}
}
  #4 (permalink)  
Old April 19th, 2010, 02:32 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I think the start of the code is fine; but thiss isn't:

Code:
Outlook.SelectNamesDialog snd = Application.Session.GetSelectNamesDialog();
Here, Application refers to the Application of ASP.NET. You need to prefix Application with something from the Oulook namespace (at least, that's what my guess is; I don't know this code so I don't know where your Application is supposed to come from). E.g. something like this:

Code:
Outlook.SelectNamesDialog snd = SomeNamespaceHereApplication.Session.GetSelectNamesDialog();
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!


Similar Threads
Thread Thread Starter Forum Replies Last Post
secure Flex application by providing Login system with Session tejas83 Flex 3 March 2nd, 2009 11:15 AM
No System.Web.UI alexanderH BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 10th, 2005 03:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.