Solved

The name '' does not exist in the current context

Posted on 2009-07-14
16
1,805 Views
Last Modified: 2013-12-17
Hi,

I get the same error, the name 'objXXXXXX' does not exist in the current context in the code I've pasted below.
I've searched the net but found no good solutions to this but I can say this about the code.
Yes I copied it from a different project and Yes I've written it from scratch, it stops at the same time over and over.


I'd be really happy to get some help with this code =)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace asdasdasdasdasdasd
{
    public partial class Form1 : Form
    {
        GroupwareTypeLibrary.Application5 objGWSession = new GroupwareTypeLibrary.Application5();
        GroupwareTypeLibrary.Account objAccount = null;
 
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            //Using Multilogin
            string sUserName = textBox3.Text;
            string sTrustedAppKey = textBox2.Text;
            string sTrustedAppName = textBox1.Text;
            string sCmdLine = "/*ipa*-127.0.0.1 /ipp-1677";
            string sWhenToPromp = "egwPromptNever";
            string sPassword = textBox4.Text;
            string sReserved = null;
            string sMessageClassName = "GW.MESSAGE.APPOINTMENT";
            string sMessageType = "egwDraft";
 
            objGWSession.SetTrustedApplicationCredentials(sTrustedAppName, sTrustedAppKey);
            objAccount = objGWSession.MultiLogin(sUserName, sCmdLine, sPassword, sWhenToPromp, sReserved);
 
            // From here the errors start saying each of the obj's( except objAccount ) does not exist in the current context.
            objMailBox = objAccount.MailBox;
            objMessages = objMailBox.Messages;
            objAppointment = objMessages.Add(sMessageType);
 
            objAppointment.Recipients.Add();
        }
    }
}

Open in new window

0
Comment
Question by:TheFlyingCorpse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
16 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24852200
You have objGWSession  & objAccount declared here:
GroupwareTypeLibrary.Application5 objGWSession = new GroupwareTypeLibrary.Application5();
        GroupwareTypeLibrary.Account objAccount = null;

but you have not declared these: objMailBox , objMessages,   objAppointment

0
 
LVL 3

Expert Comment

by:MrHswede
ID: 24852203
Where is the objMailBox, objMessages and objAppointment declared?
Cant find any declarant.
/Martin
0
 
LVL 3

Expert Comment

by:MrHswede
ID: 24852220
Typical, while writing, guru was first to hit submit...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24852436
how do I declare them? They are subtypes of the account.
It will in the end be this thing but used in the different declarations to propagate to it : GroupWareTypeLibrary.Account.MailBox.Messages.Add(sMessageType) through objMailBox, objMessages, objAppointments
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24852535
Then objMailBox should be of type objAccount.MailBox,
objMessages should be of type objMailBox.Messages

If you can share what your Account Class looks like we can get better idea.
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24852595
you mean objAccount in this case or do you mean GroupWareTypeLibrary?
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24852647
You have : GroupwareTypeLibrary.Account objAccount = null;
Yes if possible need to see the actual Class.. Account...
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24852687
yeah, I have it to = null, but it have been "= default(GroupwareTypeLibrary.Account);" without any better result.
Below is an image of the class GroupwareTypeLibrary.Class
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24852691
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24852766
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24852877
For objMailBox try this:
GroupwareTypeLibrary.Folder objMailBox = objAccount.MailBox;

If that get rids of objMailBox error ...then you have to similarly get return type of other properties like
Messages etc....

If you have any doubt...you will have to post info about Messages
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24853249
I am stuck a bit further down now, I have written a bit more to the code and I get an error about not having set Object reference to an instance of an object.

The error occurs on line 44, GroupwareTypeLibrary.Folder objMailBox = objAccount.MailBox;

Code below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace asdasdasdasdasdasd
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            GroupwareTypeLibrary.Application5 objGWSession = new GroupwareTypeLibrary.Application5();
            GroupwareTypeLibrary.Account2Class objAccount = null;
 
            
 
            //Using Multilogin
            string sUserName = textBox3.Text;
            string sTrustedAppKey = textBox2.Text;
            string sTrustedAppName = textBox1.Text;
            string sCmdLine = "/*ipa*-127.0.0.1 /ipp-1677";
            string sWhenToPromp = "egwPromptNever";
            string sPassword = textBox4.Text;
            string sReserved = null;
            string sMessageClassName = "GW.MESSAGE.APPOINTMENT";
            string sMessageType = "egwDraft";
            string sEmailAdress = "test@test.com";
            string sEmailType = "";
            string sEmailTargetTypeConst = "egwTo";
            bool bDoneSearch = false;
 
            objGWSession.SetTrustedApplicationCredentials(sTrustedAppName, sTrustedAppKey);
            //objAccount = objGWSession.MultiLogin(sUserName, sCmdLine, sPassword, sWhenToPromp, sReserved);
 
            GroupwareTypeLibrary.Folder objMailBox = objAccount.MailBox;
            GroupwareTypeLibrary.Messages objMessages = objMailBox.Messages;
            GroupwareTypeLibrary.Message objAppointment = objMessages.Add("GW.MESSAGE.APPOINTMENT", sMessageType, null);
            GroupwareTypeLibrary.Recipients objRecipients = objAppointment.Recipients;
            GroupwareTypeLibrary.Appointment objAppointment2 = default(GroupwareTypeLibrary.Appointment);
 
            //objMessages.Add(sMessageClassName, sMessageType, null);
            objRecipients.Add(sEmailAdress, sEmailType, sEmailTargetTypeConst);
            DateTime dt = DateTime.Now;
            String.Format("{0:M/dd/yyyy HH:mm:ss}", dt);
            MessageBox.Show(dt.ToString());
            
            objAppointment2.StartDate = dt;
            objAppointment2.StartBusySearch(dt, "7");
 
            do
            {
                bDoneSearch = objAppointment2.BusySearchResult.Completed;
                if (bDoneSearch == true)
                {
                    break;
                }
                else
                {
                    System.Threading.Thread.Sleep(2000);
                };
            } while (bDoneSearch == false);
 
            //objAccount.Owner.DisplayName;
            try
            {
                MessageBox.Show("DisplayName: " + objAccount.Owner.DisplayName);
            }
            catch (Exception ex)
            {
                toolStripStatusLabel1.Text = "Error in disp: " + ex.Message;
            }
 
 
        }
    }
}

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24853602
Because you don't have  objAccount  set. You are setting it initially null then this line is commented out...

//objAccount = objGWSession.MultiLogin(sUserName, sCmdLine, sPassword, sWhenToPromp, sReserved);

So before accessing objAccount.MailBox ... objAccount should not be null...
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24853960
bah, a typo :P

I uncommented it and now have an error on objApppointment2.startdate = dt; where it tells me that its not apart of an instance, use the "new" keyword to create an object instance.

I think its because I use an entirely different part of the COM object and that I dont hook it to the instance where I created the message draft as an appointment.

Any clue how I can tie this to it? ;-)


Also, I've got further now then I've ever been, this means a ton to me :)
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24854089
0
 
LVL 2

Author Comment

by:TheFlyingCorpse
ID: 24854379
thank you so much for your help, you have more then answered the initial question =)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question