By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Error getting Namespace

P: n/a
Hi,

I am trying to automate the Outlook so that I can get all
new messages received and look at them.

I have added refference "Microsoft Outlook 10.0 Object
Library" and written code:

private Outlook.Application oApp;
private Outlook._NameSpace oNameSpace;

public OutlookMail()
{

oApp = new Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
}

And that the line: oNameSpace = oApp.GetNamespace("MAPI");
it says that Outlook.Application does not contain a
definition for "GetNamespace". It does not contain the
definition for the CreateItem that I used to create new
Outlook._MailItem item.

What might be the problem?

Thatks,

Peter
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Hi Peter,

I can use the "Microsoft Outlook 10.0 Object Library" component well.
I think you should check the "References" folder in the Solution Explorer
if "Outlook" is added.
Then, you can check in the Object Browser window, if interop.outlook
assembly's Outlook|Application|_Application interface has the member
GetNamespace and CreateItem.

Btw: To get all the messages recieved like this:
oApp = new Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
Outlook.MAPIFolder
folder=oNameSpace.GetDefaultFolder(Outlook.OlDefau ltFolders.olFolderInbox);
Outlook.MailItem item=(Outlook.MailItem)folder.Items .Item(the item number
you want to display);
item.Display(null);

It works well on my machine.

Hope this helps,

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Peter Krikelis" <pk*******@hotmail.com>
| Sender: "Peter Krikelis" <pk*******@hotmail.com>
| Subject: Error getting Namespace
| Date: Fri, 10 Oct 2003 08:12:09 -0700
| Lines: 29
| Message-ID: <0d****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOPQOALVsm6Mx9xSpOP8KkiYt0SNA==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:190577
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi,
|
| I am trying to automate the Outlook so that I can get all
| new messages received and look at them.
|
| I have added refference "Microsoft Outlook 10.0 Object
| Library" and written code:
|
| private Outlook.Application oApp;
| private Outlook._NameSpace oNameSpace;
|
| public OutlookMail()
| {
|
| oApp = new Outlook.Application();
| oNameSpace = oApp.GetNamespace("MAPI");
| }
|
| And that the line: oNameSpace = oApp.GetNamespace("MAPI");
| it says that Outlook.Application does not contain a
| definition for "GetNamespace". It does not contain the
| definition for the CreateItem that I used to create new
| Outlook._MailItem item.
|
| What might be the problem?
|
| Thatks,
|
| Peter
|

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.