Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > question regarding ruby & outlook MAPI

Reply
Thread Tools

question regarding ruby & outlook MAPI

 
 
zerotrace
Guest
Posts: n/a
 
      03-15-2012
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!
 
Reply With Quote
 
 
 
 
john.fellers@gmail.com
Guest
Posts: n/a
 
      03-19-2012
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!
 
Reply With Quote
 
 
 
 
john.fellers@gmail.com
Guest
Posts: n/a
 
      03-20-2012
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??
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question regarding ruby & outlook MAPI zerotrace Ruby 0 03-15-2012 07:06 PM
MAPI extension for non-MAPI enabled email clients? hugh jass Computer Support 0 02-11-2005 12:20 PM
MAPI error in Outlook Express LB Computer Support 2 03-04-2004 08:08 PM
Open Outlook AddressBook with MAPI - Example ? Elad ASP .Net 0 01-12-2004 04:47 PM
Error occurred while initializing MAPI in Outlook Express 6 Michael MCSE 5 09-17-2003 05:39 PM



Advertisments