What Assembly contains 'Session'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brat33
    New Member
    • Jan 2010
    • 36

    #1

    What Assembly contains 'Session'

    I am modifying the following code, and continue to get a error message stating:
    The type or namespace name 'Session' could not be found (are you missing a using directive or an assembly reference?)

    This is my code:
    Code:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Net;
    using System.Net.Mail;
    using System.ServiceProcess;
    using System.Timers;
    using System.IO;
    using System.Reflection;
    using MySql.Data.MySqlClient;
    
    namespace EmailMaintHelpDesk
    {
        public class EmailToMaintTicketService : System.ServiceProcess.ServiceBase
        {
            private const string EmailServer = "mail";
            private const string EmailAccount = "mail\nmainthd";
            private const string ITEmail = "email goes here";
            private const string LogFilePath = "C:\\EmailHk\\logs\\EmailHk.log";
            private const string TTSExePath = "c:\\soe\\cgi-bin\\tts-cmd.exe";
            private const string TTSExeWorkingDirectory = "c:\\soe\\cgi-bin\\";
            private const string AttachmentFolder = "c:\\SOE\\pub\\attachments";
            private const string ttsConnectionString = "Server=localhost;Database=NAME;Uid=ID;Pwd=PW";
            private const int TimerInterval = 120000;
            private System.ComponentModel.Container components = null;
            private Timer serviceTimer = null;
            private StreamWriter log = null;
            private [B]Session[/B] mapiSession = null;
    Then of course mapiSession is referenced throughout the program in various places. I am not sure what Assembly I need to add in order to get Session recognized and usable. Any assistance would be greatly appreciated. I am also getting the same error on "AddressEnt ry" below.
    Code:
    private string GetEmailAddress([B]AddressEntry[/B] emailSender)
            {
                string exchangeAddress = emailSender.Address.ToString().ToLower();
    
                int aliasStart = exchangeAddress.LastIndexOf("=") + 1;
                int aliasLength = exchangeAddress.Length - aliasStart;
                if (aliasStart > 0) 
                {
                    string alias = exchangeAddress.Substring(aliasStart, aliasLength);
                    return String.Format("{0}@something.com", alias);
                } 
                else 
                {
                    log.WriteLine(DateTime.Now.ToString() + ": Sender email couldnt be determined -> " + exchangeAddress);
                    return "email goes here";
                }
            }
    Again AddressEntry is referenced throughout the rest of the code as well.

    This also is happening on 'Attachments'
    Code:
    private void ProcessAttachments([B]Attachments[/B] messageAttachments, 
                double unixTimestamp) 
            {
                int numberOfAttachments = (int) messageAttachments.Count;
                if (numberOfAttachments == 0) 
                    return;
                int ticketNo = GetTicketNumber(unixTimestamp);
                for (int i=1; i<numberOfAttachments+1; i++) {
                    Attachment messageAttachment 
                        = (Attachment) messageAttachments.get_Item(i);
                    string filename = (string) messageAttachment.Name;
                    string attachmentPath = String.Format(
                        "{0}\\{1}-1\\{2}",
                        AttachmentFolder, 
                        ticketNo, 
                        filename
                    );
    		 log.WriteLine(attachmentPath);
                    messageAttachment.WriteToFile(attachmentPath);
                    UpdateAttachmentsTable(filename, ticketNo);
                }
            }
    If anyone can assist me on what assemblies need to be referenced, or what I am doing wrong - I would really appreciate it!
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Probably the Microsoft.Offic e.Interop.Outlo ok namespace in the Microsoft.Offic e.Interop.Outlo ok.dll dll.

    Comment

    • brat33
      New Member
      • Jan 2010
      • 36

      #3
      When I try to add the line of code "Using Microsoft.Offic e.Interop.Outlo ok", I receive a error message that Office is not valid for namespace Microsoft. Would I just need to reference this within the solution for the dll? I am not sure what to do with this piece of information. I was expecting to add another USING line at the top of the page, but this does not seem to be the case.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Well, if it's this AddressEntry, you'll have to add a reference to Microsoft.Offic e.Interop.Outlo ok.dll to your project.

        Look at the error message:
        (are you missing a using directive or an assembly reference?)
        Lots of people don't know about the second half. You have to add a reference to a DLL before you can reference a namespace defined in that DLL. Visual Studio automatically references several DLLs for you by default, which is why just adding the Using directives is enough for them.

        Using directives are a convenience; syntactic sugar. References are not.

        Once you've added the reference, then you can add the using directive.

        Comment

        • brat33
          New Member
          • Jan 2010
          • 36

          #5
          Thanks for the additional info - that did take care of two of my three issues.

          The type or namespace name 'Session' could not be found (are you missing a using directive or an assembly reference?)

          Would you happen to know what I need to reference in order to use Session?

          Thank you so very much with the help on the other two - I have been fighting with this for over a week...Was sure I would be able to figure it out, but no luck!

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            I honestly don't know what assembly that object is from. You haven't really given much context. But I haven't worked with this kind of thing, so I really don't know what it might be.

            I'd suggest trying to find documentation from whomever you inherited this code from.

            Comment

            • brat33
              New Member
              • Jan 2010
              • 36

              #7
              Thanks again for all of your help! I was able to figure it out - I added a few more references and it seemed to accomplish what I wanted it to! Just took some more searching in addition to what I had already found! Session is in the System.Web.Mail reference!

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                Glad you found it. Just so you know, System.Web.Mail is pretty obsolete now. If you're developing new email applications, use System.Net.Mail .

                Comment

                Working...