Error getting Namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Krikelis

    Error getting Namespace

    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.Applica tion oApp;
    private Outlook._NameSp ace oNameSpace;

    public OutlookMail()
    {

    oApp = new Outlook.Applica tion();
    oNameSpace = oApp.GetNamespa ce("MAPI");
    }

    And that the line: oNameSpace = oApp.GetNamespa ce("MAPI");
    it says that Outlook.Applica tion does not contain a
    definition for "GetNamespa ce". It does not contain the
    definition for the CreateItem that I used to create new
    Outlook._MailIt em item.

    What might be the problem?

    Thatks,

    Peter
  • Jeffrey Tan[MSFT]

    #2
    RE: Error getting Namespace


    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|Applica tion|_Applicati on interface has the member
    GetNamespace and CreateItem.

    Btw: To get all the messages recieved like this:
    oApp = new Outlook.Applica tion();
    oNameSpace = oApp.GetNamespa ce("MAPI");
    Outlook.MAPIFol der
    folder=oNameSpa ce.GetDefaultFo lder(Outlook.Ol DefaultFolders. olFolderInbox);
    Outlook.MailIte m item=(Outlook.M ailItem)folder. Items .Item(the item number
    you want to display);
    item.Display(nu ll);

    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" <pkrikelis@hotm ail.com>
    | Sender: "Peter Krikelis" <pkrikelis@hotm ail.com>
    | Subject: Error getting Namespace
    | Date: Fri, 10 Oct 2003 08:12:09 -0700
    | Lines: 29
    | Message-ID: <0df301c38f40$e 00be260$a401280 a@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: AcOPQOALVsm6Mx9 xSpOP8KkiYt0SNA ==
    | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    | Path: cpmsftngxa06.ph x.gbl
    | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1905 77
    | NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.Applica tion oApp;
    | private Outlook._NameSp ace oNameSpace;
    |
    | public OutlookMail()
    | {
    |
    | oApp = new Outlook.Applica tion();
    | oNameSpace = oApp.GetNamespa ce("MAPI");
    | }
    |
    | And that the line: oNameSpace = oApp.GetNamespa ce("MAPI");
    | it says that Outlook.Applica tion does not contain a
    | definition for "GetNamespa ce". It does not contain the
    | definition for the CreateItem that I used to create new
    | Outlook._MailIt em item.
    |
    | What might be the problem?
    |
    | Thatks,
    |
    | Peter
    |

    Comment

    Working...