Please help with OLE test

Please help with OLE test

Postby Antonio Linares » Sun Dec 14, 2014 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Please help with OLE test

Postby Antonio Linares » Sun Dec 14, 2014 5:58 am

This is a workaround:

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Please help with OLE test

Postby Antonio Linares » Sun Dec 14, 2014 11:20 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Please help with OLE test

Postby driessen » Sun Dec 14, 2014 8:20 pm

Antonio,

Very strange. I always use this code :
Code: Select all  Expand view
#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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Please help with OLE test

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Re: Please help with OLE test

Postby Antonio Linares » Mon Dec 15, 2014 10:51 am

Enrico,

You can bypass it using oMailItem:To := ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Please help with OLE test

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Please help with OLE test

Postby hmpaquito » 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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Please help with OLE test

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Please help with OLE test

Postby driessen » Mon Dec 15, 2014 12:24 pm

Antonio,

You are right. Outlook has to be opened.

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

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Please help with OLE test

Postby TimStone » Mon Dec 15, 2014 5: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
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Please help with OLE test

Postby Antonio Linares » Mon Dec 15, 2014 6:41 pm

Thank you all for confirming it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests