MAPI Logon

Discussion in 'Ruby' started by Jeff Miller, Mar 26, 2008.

  1. Jeff Miller

    Jeff Miller Guest

    Hello,
    I'm trying to start up a MAPI session and get my project rolling...
    However, when I run my code below (it's supposed to just log in) I get
    an error telling me that 'MAPI.Session' is an unknown OLE server... My
    code is borrowed, but is as follows:

    require 'win32ole'
    mapiSession = WIN32OLE::new('MAPI.Session')
    WIN32OLE.const_load(mapiSession, MapiConst)
    exchangeServer = 'ex'
    mailbox = 'galthis'
    logonParam = "ProfileInfo:="+ exchangeServer + "\r" + mailbox
    mapiSession.Logon(logonParam)

    This kicks me the error:
    test_mapisession.rb:3:in `initialize': unknown OLE server:
    `MAPI.Session' (WIN32OLERuntimeError)
    HRESULT error code:0x800401f3
    Invalid class string from test_mapisession.rb:3:in `new'
    from test_mapisession.rb:3

    I don't know what I'm doing wrong, or if I need something else installed
    on my machine, I don't know... I can access MAPI outlook stuff using
    WIN32OLE.new('Outlook.Application'), but for some reason MAPI.session
    doesn't work... Any ideas?

    Any help is appreciated!

    Thanks,
    - Jeff
    --
    Posted via http://www.ruby-forum.com/.
    Jeff Miller, Mar 26, 2008
    #1
    1. Advertising

  2. Jeff Miller

    Jeff Miller Guest

    this is actually simpler to read, sorry-

    so now I've got a simple 2-liner like so:

    require 'win32ole'
    mapiSession = WIN32OLE.new('Mapi.session')

    with this error:
    test_mapisession.rb:3:in `initialize': unknown OLE server:
    `Mapi.session' (WIN32OLERuntimeError)
    HRESULT error code:0x800401f3
    Invalid class string from test_mapisession.rb:3:in `new'
    from test_mapisession.rb:3

    Any suggestions?

    Thanks,
    - Jeff
    --
    Posted via http://www.ruby-forum.com/.
    Jeff Miller, Mar 26, 2008
    #2
    1. Advertising

  3. Jeff Miller

    David Mullet Guest

    Jeff Miller wrote:
    > this is actually simpler to read, sorry-
    >
    > so now I've got a simple 2-liner like so:
    >
    > require 'win32ole'
    > mapiSession = WIN32OLE.new('Mapi.session')
    >
    > with this error:
    > test_mapisession.rb:3:in `initialize': unknown OLE server:
    > `Mapi.session' (WIN32OLERuntimeError)
    > HRESULT error code:0x800401f3
    > Invalid class string from test_mapisession.rb:3:in `new'
    > from test_mapisession.rb:3
    >
    > Any suggestions?
    >
    > Thanks,
    > - Jeff


    I think you may need to have CDO (or CDONTS) installed separately in
    order to call access the MAPI namespace directly. I think MAPI.Session
    resides in the CDO.dll file.

    Otherwise, you can call it through Outlook (assuming you have Outlook
    installed):

    require 'win32ole'
    outlook = WIN32OLE.new('Outlook.Application')
    mapi = outlook.GetNameSpace('MAPI')

    http://rubyonwindows.blogspot.com/search/label/outlook

    Hope that helps.

    David

    http://rubyonwindows.blogspot.com
    --
    Posted via http://www.ruby-forum.com/.
    David Mullet, Mar 27, 2008
    #3
  4. Jeff Miller

    Jeff Miller Guest

    Thanks guys, that helped!

    I am now on a dev box that has Exchange System Manager installed, giving
    me access to MAPI32 and CDO. My session and logon work great now, but I
    can't seem to get any further using the same type of code that I used
    for Outlook MAPI previously. I want to return a list of folders, but
    nothing I've tried seems to work.

    When I do the following:
    require 'win32ole'
    session = WIN32OLE.new('Mapi.session')
    session.logon('profilename')

    What can I use to gain access to mailboxes? Previously, for Outlook
    MAPI, I used:

    outlook = WIN32OLE.new('Outlook.Application')
    mapi = outlook.GetNameSpace('MAPI')
    mailbox = mapi.Folders.Item("Mailbox - USERNAME")
    contacts_folder = mailbox.Folders.Item("Contacts")

    Where 'mailbox' defines which mailbox to use. However, I don't think I
    can do that the same way for Exchange MAPI. Does anyone know how to do
    this or have any experience with it?

    Any and all help is appreciated!

    Thanks!!!
    --
    Posted via http://www.ruby-forum.com/.
    Jeff Miller, Mar 27, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ted
    Replies:
    1
    Views:
    558
    DM McGowan II
    Jul 3, 2004
  2. Pat Sinnott
    Replies:
    0
    Views:
    1,248
    Pat Sinnott
    Jul 7, 2003
  3. Suganthi

    Mapi Logon problem

    Suganthi, Jul 21, 2003, in forum: C++
    Replies:
    1
    Views:
    2,438
    Jack Klein
    Jul 21, 2003
  4. Kjell Kristiansson
    Replies:
    0
    Views:
    282
    Kjell Kristiansson
    Nov 30, 2005
  5. Adam Kinney

    MAPI.Profile Logon with ASP

    Adam Kinney, Feb 10, 2004, in forum: ASP General
    Replies:
    2
    Views:
    199
    Lee Derbyshire
    Feb 11, 2004
Loading...

Share This Page