# Seeking win32ole CDO/Mapi help

**URL:** <https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241>\
**Category:** Ruby\
**Created:** [March 28, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241 "2006-03-28T17:20:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/49beb7/32.png) [@ksader](https://www.ruby-forum.com/u/ksader)\
**Post date:** [March 28, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241/1 "2006-03-28T17:20:27Z")

</div>

I’m trying to read a remote mail store using the CDO OLE interface  
using the ProfileInfo interface as described here:  
[http://www.vbip.com/books/1861002068/chapter\_2068\_04.asp](http://www.vbip.com/books/1861002068/chapter_2068_04.asp), but I’ve run  
into the wall of my own ignorance.

Here’s what I have so far:

# Ruby code

require ‘win32ole’

mapiSession = WIN32OLE::new(‘MAPI.Session’)

#load MAPI constants  
class MapiConst  
end  
WIN32OLE.const\_load(mapiSession, MapiConst)

exchangeServer = 'myServer  
mailbox = ‘removed\_email\_address@domain.invalid’  
logonParam = “ProfileInfo:=”+ exchangeServer + “\r” + mailbox  
mapiSession.Logon(logonParam)

# the rest of the code…

However the Logon method throws the following set of exceptions.

First I get a pop-up dialog stating that the Profile Name contains  
invalid characters.

From the above link: “The ProfileInfo is a string that consists of  
three parts. The first is the name of the Exchange Server. The second  
is always a linefeed character.”

I think part of my problem is I’m not getting the correct character in  
as the linefeed. Can someone validate that? Maybe I’m missing and  
easy Ruby trick to add a linefeed to a string?

The other exception is as follows:

Logon  
OLE error code:1087 in Collaboration Data Objects  
[Collaboration Data Objects - [E\_INVALIDARG(80070057)]]  
HRESULT error code:0x80020009  
Exception occurred.  
C:/devenv/Client  
Application/RubyReplacement/ExampleOutlookScript.rb:13:in  
`method_missing' C:/devenv/Client Application/RubyReplacement/ExampleOutlookScript.rb:13 C:/devenv/Client Application/RubyReplacement/ExampleOutlookScript.rb:13:in `method\_missing’: Logon (WIN32OLERuntimeError)  
OLE error code:1087 in Collaboration Data Objects  
[Collaboration Data Objects - [E\_INVALIDARG(80070057)]]  
HRESULT error code:0x80020009  
Exception occurred.

Which I think is the result of the first error.

thanks,

---

<div class="post-metadata">

**Author:** ![ksader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/49beb7/32.png) [@ksader](https://www.ruby-forum.com/u/ksader)\
**Post date:** [March 28, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241/2 "2006-03-28T17:29:30Z")

</div>

On 3/28/06, Keith S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> mapiSession.Logon(logonParam)
> 
> I think part of my problem is I’m not getting the correct character in  
> as the linefeed. Can someone validate that? Maybe I’m missing and  
> easy Ruby trick to add a linefeed to a string?

I believe linefeed is \n and \r is carriage return.

---

<div class="post-metadata">

**Author:** ![ksader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/49beb7/32.png) [@ksader](https://www.ruby-forum.com/u/ksader)\
**Post date:** [March 28, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241/3 "2006-03-28T17:41:13Z")

</div>

While I was explaining it to a co-worker, I stumbled upon a weird  
feature of the VB OLE call. The VB OLE call can do a weird  
short-circuit and not need the other parameters.

If I change the call to Logon to mapiSession.Logon(nil, nil, nil, nil,  
nil, nil, logonParam), it doesn’t give me the first set of dialogs  
complaining about the invalid charaters, but I still get the 1087  
error. Maybe some of the other fields need to not be nil?

thanks,

---

<div class="post-metadata">

**Author:** ![ksader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/49beb7/32.png) [@ksader](https://www.ruby-forum.com/u/ksader)\
**Post date:** [March 29, 2006, 5:35am UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241/4 "2006-03-29T05:35:05Z")

</div>

My sincere apologies for being so dense. Yes that was it using

logonParam = “ProfileInfo:=”+ exchangeServer + “\n” + mailbox

instead of \r made everything all better.

Now I must go bang my head into the wall some more 🙂

thanks,

---

<div class="post-metadata">

**Author:** ![ksader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/49beb7/32.png) [@ksader](https://www.ruby-forum.com/u/ksader)\
**Post date:** [March 28, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/seeking-win32ole-cdo-mapi-help/89241/5 "2006-03-28T18:53:52Z")

</div>

Sorry for the double posts, I don’t know why gmail is doing that…
