Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 18th, 2010, 11: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, 01:36 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 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 19th, 2010, 12:44 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'

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, 03:32 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 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!
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 06:48 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.