new MAPI.Session() does not work!?!?!?

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

    #1

    new MAPI.Session() does not work!?!?!?

    I am writing a program in C# which accesses data from Exchange. Code
    snippets have been copied from a VB-program.

    The VB-program does the following:

    'create session and logon
    objSession = CreateObject("M API.Session")

    After this, everyhing works fine.

    In c# this looks like:

    'create session and logon
    objSession = new MAPI.Session();

    And this does not work!?!? I get an error stating that Outlook is not
    the default client or that the mail client cannot fullfil the
    messaging request. Then i also get an exception: ClassFactory cannot
    supply requested class.

    Can anyone help me on this one? Everything concentrates on the
    creation of the session object. In VB.NET it works, in C# not?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: new MAPI.Session() does not work!?!?!?

    Gerry,

    I forgot to mention, the reason it doesn't work is that MAPI.Session
    (when imported) is the name of an interface, not a class. VB6 obfuscated
    classes and interfaces (quite poorly I might add). You can create an
    instance of MAPI.SessionCla ss and it should work.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Gerry" <gerry.van.den. broek@logicacmg .com> wrote in message
    news:49f5b133.0 310280338.70cbd 10b@posting.goo gle.com...[color=blue]
    > I am writing a program in C# which accesses data from Exchange. Code
    > snippets have been copied from a VB-program.
    >
    > The VB-program does the following:
    >
    > 'create session and logon
    > objSession = CreateObject("M API.Session")
    >
    > After this, everyhing works fine.
    >
    > In c# this looks like:
    >
    > 'create session and logon
    > objSession = new MAPI.Session();
    >
    > And this does not work!?!? I get an error stating that Outlook is not
    > the default client or that the mail client cannot fullfil the
    > messaging request. Then i also get an exception: ClassFactory cannot
    > supply requested class.
    >
    > Can anyone help me on this one? Everything concentrates on the
    > creation of the session object. In VB.NET it works, in C# not?[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: new MAPI.Session() does not work!?!?!?

      Gerry,

      You might want to use CreateObject in C# as well, through the
      Microsoft.Visua lBasic library. You could set a reference to
      Microsoft.Visua lBasic and then access the static CreateObject method through
      the Interaction class in the Microsoft.Visua lBasic namespace. This should
      give you the same results.

      Hope this helps.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "Gerry" <gerry.van.den. broek@logicacmg .com> wrote in message
      news:49f5b133.0 310280338.70cbd 10b@posting.goo gle.com...[color=blue]
      > I am writing a program in C# which accesses data from Exchange. Code
      > snippets have been copied from a VB-program.
      >
      > The VB-program does the following:
      >
      > 'create session and logon
      > objSession = CreateObject("M API.Session")
      >
      > After this, everyhing works fine.
      >
      > In c# this looks like:
      >
      > 'create session and logon
      > objSession = new MAPI.Session();
      >
      > And this does not work!?!? I get an error stating that Outlook is not
      > the default client or that the mail client cannot fullfil the
      > messaging request. Then i also get an exception: ClassFactory cannot
      > supply requested class.
      >
      > Can anyone help me on this one? Everything concentrates on the
      > creation of the session object. In VB.NET it works, in C# not?[/color]


      Comment

      Working...