FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Please help with OLE test
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Please help with OLE test
Posted: Sun Dec 14, 2014 05:40 AM

Could you please test this code (only if you have Outlook installed on your computer) ?

local oOutlook := CreateObject( "Outlook.Application" )
local oMailItem := oOutlook:CreateItem( 0 )

oMailItem:Subject = "Test"
oMailItem:Recipients:Add( "test@gmail.com" ) // it is failing here

I am interested in different Harbour and xHarbour versions.

It seems to me as a Harbour OLE automation error. But I am not sure yet, thats why we need to confirm it

Many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Sun Dec 14, 2014 05:58 AM

This is a workaround:

oMailItem:To = "alinares@fivetechsoft.com; antonio.fivetech@gmail.com"

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Sun Dec 14, 2014 11:20 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Please help with OLE test
Posted: Sun Dec 14, 2014 08:20 PM
Antonio,

Very strange. I always use this code :
Code (fw): Select all Collapse
#INCLUDE "MAIL.CH"

..................

local EmSend    := .T.
local ErOutlook,ErMail,ErNameSpace

..................

TRY
   GetActiveObject("Outlook.Application")
CATCH
   ShellExecute(,"Open","Outlook",,,7)
END
TRY
   ErOutLook   := TOleAuto():New("Outlook.Application")
   ErNameSpace := ErOutLook:GetNameSpace("MAPI")
   EmSend      := .T.
CATCH
   EmSend      := .F.
END
TRY
   IF EmSend
      ErMail         := ErOutlook:CreateItem(olMailItem)
      ErMail:Subject := ALLTRIM("Juda(32)-foutmelding - " + ALLTRIM(PAR->GKANTOOR))
      ErMail:Body    := "Klant : " + ALLTRIM(PAR->GKANTOOR) + CRLF + "Gebruiker : " + ALLTRIM(US->USERNAAM) + CRLF + "Datum : " + DTOC(DATE()) + CRLF + "Uur : " + TIME() + CRLF + CRLF + "Juda(32)-foutmelding : zie bijlage !!!"
      ErMail:Recipients:Add("michel.driessen@ma-consult.be")
      ErMail:Attachments:Add(EmFile)
      ErMail:Display()
   ENDIF
CATCH
    EmSend := .F.
END
This code is working just fine in Harbour as well as in xHarbour, with different versions of Outlook starting 2007.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Sun Dec 14, 2014 10:14 PM

Michel,

Don't know why but now it is working fine. I have just tested it again.

Really strange but now is working. Outlook mistery ? :-)

many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 10:28 AM

Still errors out here. :-(

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 10:51 AM

Enrico,

You can bypass it using oMailItem:To := ...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 10:51 AM

Enrico,

Please open outlook previously and once is shown, try your code again, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 11:06 AM

Antonio,

Outlook y Excel para mi tambien son un misterio. Muchas veces he tenido errores que he podido sortear buscando un rodeo con metodos alternativos.

Una buena manera de controlar como hacer las cosas o dejar de hacer algunas, sino hay alternativa, es mirando la version de excel / outlook

De esta manera tenemos que outlook (o excel) son version-dependientes... algo que facilita que en el futuro, con las actualizacion de outlook nuestro software haga crash.

Solucion radical: no usarlos.

Saludos

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 11:40 AM
Antonio,

Antonio Linares wrote:Enrico,

Please open outlook previously and once is shown, try your code again, thanks :-)


Yes, it works fine if I open Outlook before running my sample.

EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 12:24 PM
Antonio,

You are right. Outlook has to be opened.

That's why I start with :
Code (fw): Select all Collapse
TRY
   GetActiveObject("Outlook.Application")
CATCH
   ShellExecute(,"Open","Outlook",,,7)
END

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 05:09 PM

That is not unusual. Other programs also require Outlook to be open. Outlook runs 24/7 on my computers so of course it would already be open anyway.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Please help with OLE test
Posted: Mon Dec 15, 2014 06:41 PM

Thank you all for confirming it :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion