------art_8290_6825551.1206046372554
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thu, Mar 20, 2008 at 12:21 PM, Jeff Miller <loadeddesigns / gmail.com>
wrote:

> Hello Everybody,
>  I'm trying to make a Ruby Script that adds contacts to Microsoft
> outlook via Ruby's Win32OLE and MAPI. So it works for the most part, but
> I'm having trouble trying to handle exceptions... The big problem right
> now is that the contacts need to go into a subfolder. However, if the
> current mailbox doesn't have the specified subfolder, it kicks an
> exception. Thus, I added a line of code to add that folder. However, if
> the folder doesn't exist, it kicks an error, and if it tries to create
> it when it does exist, it kicks an error. I've tried IF statements and
> UNLESS statements, but I'm not getting anywhere... My code is as
> follows:
>
> outlook  IN32OLE.new('Outlook.Application')
> mapi  utlook.GetNameSpace('MAPI')
> contacts_folder  api.GetDefaultFolder(10)
>
> if contacts_folder.Folders("Company Contacts")
>  co_contacts  api.GetDefaultFolder(10).Folders("Company Contacts")
>  else
>  co_contacts  api.GetDefaultFolder(10).Folders.Add("Company
> Contacts")
> end
>
> when contacts_folder.Folder("Company Contacts") does not exist, it
> doesn't do the ELSE portion of the IF statement. It kicks me the error
> "The operation failed. An object could not be found". Does anyone know
> how to handle this?
>
> Any help is appreciated!!
>
> Thanks,
>  - Jeff Miller
> --
> Posted via http://www.ruby-forum.com/.
>
>
Off the top of my head I would guess it is returning something other than
nil or false which is why you aren't hitting your else, what it would be
returning I have no idea.

-- 
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

------art_8290_6825551.1206046372554--