win32ole and ms outlook (OLE) 
Author Message
 win32ole and ms outlook (OLE)

Hello All,

Anyone have any difficulty creating a mail message via win32ole? It
should look something like this:

olApp = WIN32OLE.new("Outlook.Application")
olMail = olApp.CreateItem(olMailItem)
olMail.display()

thxs

KK



Tue, 04 May 2004 04:02:35 GMT  
 win32ole and ms outlook (OLE)

Quote:
> olApp = WIN32OLE.new("Outlook.Application")
> olMail = olApp.CreateItem(olMailItem)
> olMail.display()

Can you post the error(s) you're getting?

Is olMailItem a defined Ruby variable?

Chris



Tue, 04 May 2004 04:36:32 GMT  
 win32ole and ms outlook (OLE)
Chris,

Thanks for your help.  I am pretty new to Ruby. I am actually more
familiar with VB (which isn't bad if you don't need to parse strings)
and Python.

Here is a copy of the error:

C:\ruby\bin\rwlib\olTest.rb:3: undefined local variable or method
`olMailItem' for #<Object:0xa04bcd0>(NameError)

    from C:\ruby\bin\rwlib\olTest.rb:3
    from C:\ruby\bin\rwlib\olTest.rb:0

'olMailItem' is a predefined object from Outlook's object model (there
are several objects...folders, calenders etc). The 'CreateItem' method
takes this as it argument. I also tried passing the value "0" which is
the integer representation of that object. I am assuming the via the
WIN32OLE module that I have access to the full object model?  I
haven't had many problems with excel or word. If my syntax is wrong,
please correct me.

thxs,
KK



Tue, 04 May 2004 22:08:32 GMT  
 win32ole and ms outlook (OLE)

Quote:
> 'olMailItem' is a predefined object from Outlook's object model (there
> are several objects...folders, calenders etc). The 'CreateItem' method
> takes this as it argument. I also tried passing the value "0" which is
> the integer representation of that object. I am assuming the via the
> WIN32OLE module that I have access to the full object model?  I
> haven't had many problems with excel or word. If my syntax is wrong,
> please correct me.

> thxs,
> KK

OK,
I had never done it but a quick check at the msdn and the ruby book tells me
olMailItem is a constant and that such constant needs to be explicitly
loaded
in a class to be available. So I did:

irb(main):024:0> class OutlookConst
irb(main):025:1> end
nil
irb(main):026:0> OutlookConst.inspect
"OutlookConst"
irb(main):027:0> WIN32OLE.const_load(olApp, Outlook)

then
irb(main):028:0> Outlook.constants
["OlRemoteUser", "OlTaskRequestUpdate", "OlMenu", "OlFolders", "OlNumber",
"OlHome", "OlPersonal",
..."OlMailItem"...
]
ok so the constant names have an uppercase first later to comply with ruby's
idea of a constant.

then
irb(main):031:0> oleApp.CreateItem(Outlook::OlMailItem)
#<WIN32OLE:0x100b8bc8>
victory ;-)
Benoit



Thu, 06 May 2004 22:33:28 GMT  
 win32ole and ms outlook (OLE)
Benoit,

Thank You.  That helps alot!

kk

Quote:

> > 'olMailItem' is a predefined object from Outlook's object model (there
> > are several objects...folders, calenders etc). The 'CreateItem' method
> > takes this as it argument. I also tried passing the value "0" which is
> > the integer representation of that object. I am assuming the via the
> > WIN32OLE module that I have access to the full object model?  I
> > haven't had many problems with excel or word. If my syntax is wrong,
> > please correct me.

> > thxs,
> > KK
> OK,
> I had never done it but a quick check at the msdn and the ruby book tells me
> olMailItem is a constant and that such constant needs to be explicitly
> loaded
> in a class to be available. So I did:

> irb(main):024:0> class OutlookConst
> irb(main):025:1> end
> nil
> irb(main):026:0> OutlookConst.inspect
> "OutlookConst"
> irb(main):027:0> WIN32OLE.const_load(olApp, Outlook)

> then
> irb(main):028:0> Outlook.constants
> ["OlRemoteUser", "OlTaskRequestUpdate", "OlMenu", "OlFolders", "OlNumber",
> "OlHome", "OlPersonal",
> ..."OlMailItem"...
> ]
> ok so the constant names have an uppercase first later to comply with ruby's
> idea of a constant.

> then
> irb(main):031:0> oleApp.CreateItem(Outlook::OlMailItem)
> #<WIN32OLE:0x100b8bc8>
> victory ;-)
> Benoit



Fri, 07 May 2004 23:42:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. MS OUTLOOK, MS PROJECT replication.

2. Python w/MS Outlook / MS Exchange

3. Need help with win32ole control of ms dom

4. Ole and Outlook express

5. M$ Outlook OLE in Clarion

6. Object Rexx using OLE to create message in Outlook

7. Dolphin App + MS Outlook

8. Clarion 5.0 --> MS-Outlook

9. Communicating to MS-Outlook

10. Adding a calander entry to MS Outlook 2000

11. Getting Events from MS-Outlook

12. CW2.003 and MS Outlook 97/98

 

 
Powered by phpBB® Forum Software