Error getting Namespace

P

Peter Krikelis

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
 
J

Jeffrey Tan[MSFT]

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.OlDefaultFolders.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" <[email protected]>
| Sender: "Peter Krikelis" <[email protected]>
| Subject: Error getting Namespace
| Date: Fri, 10 Oct 2003 08:12:09 -0700
| Lines: 29
| Message-ID: <[email protected]>
| 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
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top