Discussion:
Help with Outlook mail object detection
(too old to reply)
GDFord
2011-09-26 21:54:27 UTC
Permalink
I need to get the class of an item in Outlook so I know if it is a valid
mail item.
I can't get the class property to work.
Can someone please help me determine what kind if items they are?

function mytest()
local oOutlook, oExp, oItem, nClass, tReceived
oOutlook := TOleAuto():New( "Outlook.Application" )
oExp := oOutlook:ActiveExplorer
oItem := myOlExp:Selection:Item(1)
// oItem:Class is supposed to return the class of the item object.
// if oItem:Class = 42 then it should be an
// email object but it returns another object.
nClass := oItem:Class
tracelog( nClass )
// If the current item is a regular
// email then the following line works.
// If the current item is an undeliverable
// message or something other than mail
// thenthe following line fails
tReceived := oItem:ReceivedTime
return nil
GDFord
2011-09-30 20:24:49 UTC
Permalink
Nobody can help me with this?
Post by GDFord
I need to get the class of an item in Outlook so I know if it is a valid
mail item.
I can't get the class property to work.
Can someone please help me determine what kind if items they are?
function mytest()
local oOutlook, oExp, oItem, nClass, tReceived
oOutlook := TOleAuto():New( "Outlook.Application" )
oExp := oOutlook:ActiveExplorer
oItem := myOlExp:Selection:Item(1)
// oItem:Class is supposed to return the class of the item object.
// if oItem:Class = 42 then it should be an
// email object but it returns another object.
nClass := oItem:Class
tracelog( nClass )
// If the current item is a regular
// email then the following line works.
// If the current item is an undeliverable
// message or something other than mail
// thenthe following line fails
tReceived := oItem:ReceivedTime
return nil
dlzc
2011-09-30 21:48:47 UTC
Permalink
Post by GDFord
Nobody can help me with this?
Sorry I reviewed posts here and on the old newsgroup for instances of
"Selection:Item", and found squat.

I look on Micro$haft's website:
http://msdn.microsoft.com/en-us/library/ff868001.aspx
... but it just confuses me so...

David A. Smith
GDFord
2011-10-02 00:16:18 UTC
Permalink
Post by dlzc
Post by GDFord
Nobody can help me with this?
Sorry I reviewed posts here and on the old newsgroup for instances of
"Selection:Item", and found squat.
http://msdn.microsoft.com/en-us/library/ff868001.aspx
... but it just confuses me so...
David A. Smith
Yes, I have done the same thing. Everything I try from Microsoft
examples seems to error. I might have to use an error block so it
catches non mail items.
Ron Pinkas
2011-10-04 19:38:22 UTC
Permalink
You don't explain what problem you have. For me the :Class property does
return a number, which happens to be 43. You do have to have Outlook OPENed
by the user, and some item should be selected.

Ron
GDFord
2011-10-05 20:38:41 UTC
Permalink
Post by Ron Pinkas
You don't explain what problem you have. For me the :Class property does
return a number, which happens to be 43. You do have to have Outlook
OPENed by the user, and some item should be selected.
Ron
Thanks Ron for your interest.

It does work if I do not have #include "fivewin.ch"

If I try to do this within a fivewin application
tracelog() shows that it creates a toleauto object.
[testmail.prg->MYTEST] (11)
Type: O >>>{ TOLEAUTO Object }<<<

With just xHb application it returns a numeric which is correct.

Here is the exact code that fails.
///////
#INCLUDE "FIVEWIN.CH"
function mytest()
local oOutlook, oExp, oItem, nClass, tReceived
oOutlook := TOleAuto():New( "Outlook.Application" )
oExp := oOutlook:ActiveExplorer
oItem := oExp:Selection:Item(1)
// oItem:Class is supposed to return the class of the item object.
// if oItem:Class = 42 then it should be an
// email object but it returns another object.
nClass := oItem:Class
tracelog( nClass )
// If the current item is a regular
// email then the following line works.
// If the current item is an undeliverable
// message or something other than mail
// thenthe following line fails
tReceived := oItem:ReceivedTime
return nil
dlzc
2011-10-05 22:22:52 UTC
Permalink
Post by GDFord
Post by Ron Pinkas
You don't explain what problem you have. For me the
:Class property does return a number, which happens
to be 43. You do have to have Outlook OPENed by the
user, and some item should be selected.
Thanks Ron for your interest.
It does work if I do not have #include "fivewin.ch"
If I try to do this within a fivewin application
tracelog() shows that it creates a toleauto object.
[testmail.prg->MYTEST] (11)
Type: O >>>{ TOLEAUTO Object }<<<
With just xHb application it returns a numeric which is correct.
Then you can encapsulate this into a LIB file, and compile it
separately... correctly pointing to xHarbour internals, maybe?
Post by GDFord
Here is the exact code that fails.
///////
#INCLUDE "FIVEWIN.CH"
function mytest()
   local oOutlook, oExp, oItem, nClass, tReceived
   oOutlook := TOleAuto():New( "Outlook.Application" )
   oExp := oOutlook:ActiveExplorer
   oItem := oExp:Selection:Item(1)
   // oItem:Class is supposed to return the class of the item object.
   // if oItem:Class = 42 then it should be an
   // email object but it returns another object.
   nClass := oItem:Class
   tracelog( nClass )
   // If the current item is a regular
   // email then the following line works.
   // If the current item is an undeliverable
   // message or something other than mail
   // thenthe following line fails
   tReceived := oItem:ReceivedTime
return nil
They have redefined the calls, so you will need to ask whereever you
get help for FiveWin.

David A. Smith
Ron Pinkas
2011-10-06 16:46:18 UTC
Permalink
It does work if I do not have #include "fivewin.ch"
Post by GDFord
If I try to do this within a fivewin application
tracelog() shows that it creates a toleauto object.
[testmail.prg->MYTEST] (11)
Type: O >>>{ TOLEAUTO Object }<<<
With just xHb application it returns a numeric which is correct.
Did you try to compile both variations to .ppo and compare the files
(except the obvious bagage of fwh)?

I suspect you will discover the cause and will have to report it to
Antonio.

Ron
GDFord
2011-10-06 18:44:29 UTC
Permalink
Post by GDFord
It does work if I do not have #include "fivewin.ch"
Post by GDFord
If I try to do this within a fivewin application
tracelog() shows that it creates a toleauto object.
[testmail.prg->MYTEST] (11)
Type: O>>>{ TOLEAUTO Object }<<<
With just xHb application it returns a numeric which is correct.
Did you try to compile both variations to .ppo and compare the files
(except the obvious bagage of fwh)?
I suspect you will discover the cause and will have to report it to
Antonio.
Ron
Good call.
It stripped off :Class so that it was
nClass := oItem
when it should have been
nClass := oItem:Class
I tried calling it in another .prg without fivewin include and I got it
working.

Thanks, Ron

Loading...