question regarding ruby & outlook MAPI

Discussion in 'Ruby' started by zerotrace, Mar 15, 2012.

  1. zerotrace

    zerotrace Guest

    Hello list:

    I am accessing outlook with ruby through a MAPI connection. I have
    created a folder through OWA called 'archive'. My goal is to process
    the message and then move it into this folder. I am trying to find out
    how to 'set' or reference this folder in the code. I have been
    unsuccessful and thought I would reach out to see if anyone can point
    me in the right direction... example of my code:

    ol = WIN32OLE.new('Outlook.Application')
    class OC; end
    WIN32OLE.const_load(ol, OC)
    mapi = ol.GetNameSpace('MAPI')
    inbox = mapi.GetDefaultFolder(OC::OlFolderInbox)
    items = inbox.items
    items.sort('ReceivedTime', OC::OlAscending)

    ### parse message and move to archive folder
    items.each do |message|
    if message.UnRead
    puts "This message is unread!"
    ###parse message
    message.Move(archive_folder)
    else
    puts "Nothing to process.... ")
    end
    end


    I am not quite sure how to set the folder I created called 'archive'.
    does anyone have any ideas how I would set this in a variable somehow,
    so I can reference like so:
    archive_folder = mapi.Folders("archive") <-------(this does not work
    BTW)

    thank you in advance!
     
    zerotrace, Mar 15, 2012
    #1
    1. Advertising

  2. zerotrace

    Guest

    On Thursday, March 15, 2012 3:06:55 PM UTC-4, zerotrace wrote:
    > Hello list:
    >
    > I am accessing outlook with ruby through a MAPI connection. I have
    > created a folder through OWA called 'archive'. My goal is to process
    > the message and then move it into this folder. I am trying to find out
    > how to 'set' or reference this folder in the code. I have been
    > unsuccessful and thought I would reach out to see if anyone can point
    > me in the right direction... example of my code:
    >
    > ol = WIN32OLE.new('Outlook.Application')
    > class OC; end
    > WIN32OLE.const_load(ol, OC)
    > mapi = ol.GetNameSpace('MAPI')
    > inbox = mapi.GetDefaultFolder(OC::OlFolderInbox)
    > items = inbox.items
    > items.sort('ReceivedTime', OC::OlAscending)
    >
    > ### parse message and move to archive folder
    > items.each do |message|
    > if message.UnRead
    > puts "This message is unread!"
    > ###parse message
    > message.Move(archive_folder)
    > else
    > puts "Nothing to process.... ")
    > end
    > end
    >
    >
    > I am not quite sure how to set the folder I created called 'archive'.
    > does anyone have any ideas how I would set this in a variable somehow,
    > so I can reference like so:
    > archive_folder = mapi.Folders("archive") <-------(this does not work
    > BTW)
    >
    > thank you in advance!


    anyone have and advice on this, or can point me in the right direction? Your help is appreciated!
     
    , Mar 19, 2012
    #2
    1. Advertising

  3. zerotrace

    Guest

    On Thursday, March 15, 2012 3:06:55 PM UTC-4, zerotrace wrote:
    > Hello list:
    >
    > I am accessing outlook with ruby through a MAPI connection. I have
    > created a folder through OWA called 'archive'. My goal is to process
    > the message and then move it into this folder. I am trying to find out
    > how to 'set' or reference this folder in the code. I have been
    > unsuccessful and thought I would reach out to see if anyone can point
    > me in the right direction... example of my code:
    >
    > ol = WIN32OLE.new('Outlook.Application')
    > class OC; end
    > WIN32OLE.const_load(ol, OC)
    > mapi = ol.GetNameSpace('MAPI')
    > inbox = mapi.GetDefaultFolder(OC::OlFolderInbox)
    > items = inbox.items
    > items.sort('ReceivedTime', OC::OlAscending)
    >
    > ### parse message and move to archive folder
    > items.each do |message|
    > if message.UnRead
    > puts "This message is unread!"
    > ###parse message
    > message.Move(archive_folder)
    > else
    > puts "Nothing to process.... ")
    > end
    > end
    >
    >
    > I am not quite sure how to set the folder I created called 'archive'.
    > does anyone have any ideas how I would set this in a variable somehow,
    > so I can reference like so:
    > archive_folder = mapi.Folders("archive") <-------(this does not work
    > BTW)
    >
    > thank you in advance!




    On Thursday, March 15, 2012 3:06:55 PM UTC-4, zerotrace wrote:
    > Hello list:
    >
    > I am accessing outlook with ruby through a MAPI connection. I have
    > created a folder through OWA called 'archive'. My goal is to process
    > the message and then move it into this folder. I am trying to find out
    > how to 'set' or reference this folder in the code. I have been
    > unsuccessful and thought I would reach out to see if anyone can point
    > me in the right direction... example of my code:
    >
    > ol = WIN32OLE.new('Outlook.Application')
    > class OC; end
    > WIN32OLE.const_load(ol, OC)
    > mapi = ol.GetNameSpace('MAPI')
    > inbox = mapi.GetDefaultFolder(OC::OlFolderInbox)
    > items = inbox.items
    > items.sort('ReceivedTime', OC::OlAscending)
    >
    > ### parse message and move to archive folder
    > items.each do |message|
    > if message.UnRead
    > puts "This message is unread!"
    > ###parse message
    > message.Move(archive_folder)
    > else
    > puts "Nothing to process.... ")
    > end
    > end
    >
    >
    > I am not quite sure how to set the folder I created called 'archive'.
    > does anyone have any ideas how I would set this in a variable somehow,
    > so I can reference like so:
    > archive_folder = mapi.Folders("archive") <-------(this does not work
    > BTW)
    >
    > thank you in advance!


    BUMP! anyone have any experience with this, or have encountered this in the past??
     
    , Mar 20, 2012
    #3
    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. Elad
    Replies:
    0
    Views:
    750
  2. Mark Hahn
    Replies:
    1
    Views:
    954
    Syver Enstad
    Sep 12, 2003
  3. Chris

    Fun with Outlook and MAPI

    Chris, Dec 10, 2004, in forum: Python
    Replies:
    14
    Views:
    2,306
    Steve Holden
    Dec 13, 2004
  4. V.C.Sekhar

    Outlook-MAPI

    V.C.Sekhar, May 9, 2005, in forum: Python
    Replies:
    1
    Views:
    4,328
  5. zerotrace
    Replies:
    0
    Views:
    562
    zerotrace
    Mar 15, 2012
Loading...

Share This Page