FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ¿Alguna funcion para enviar email desatendido xHarbour?
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Tue Jan 26, 2021 03:07 PM
Rick Lipkin wrote:Armondo

Use try\catch
Code (fw): Select all Collapse
Try
   oOutLook: = TOleAuto ( ) : New ( "Outlook.Application" )
Catch
    Saying: = "For some Odd reason The Outlook e-mail CLient failed to Initialize"
    Msginfo ( Saying )
    Return ( .f. )
End Try


Rick Lipkin


Good ! Thanks a Lot Rick !! :-)
"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Tue Jan 26, 2021 03:11 PM

Rick:

Thanks a lot.

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Tue Jan 26, 2021 09:09 PM

Todavia sigo sin poder resolver el envio de email...

Alguna mano amiga ??

"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 11
Joined: Thu Jun 06, 2019 01:15 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Wed Jan 27, 2021 06:42 AM

Cuál es el problema exacto que tienes?

Enviado desde mi moto g(7) plus mediante Tapatalk

Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Wed Jan 27, 2021 12:45 PM
José

Intenta de ésta forma
Code (fw): Select all Collapse
Function EnviaCorreo(Cuerpo,Asunto,Adj)
 local oMsg := CreateObject( "CDO.Message" )
 local oConf := CreateObject( "CDO.Configuration" )
 local cSchema := "http://schemas.microsoft.com/cdo/configuration/"
 Local lOk := .T.,oError
 
oError:=NIL
TRY
 oConf:Fields[ cSchema + "smtpusessl" ] = .T. 
 oConf:Fields[ cSchema + "smtpauthenticate" ] = 1
 oConf:Fields[ cSchema + "sendusername" ] = "cuenta@gmail.com" 
 oConf:Fields[ cSchema + "sendpassword" ] = "password"
 oConf:Fields[ cSchema + "smtpserver" ] = "smtp.gmail.com"
 oConf:Fields[ cSchema + "sendusing" ] = 2
 oConf:Fields[ cSchema + "smtpserverport" ] = 465 
        
 oConf:Fields:Update()

 oMsg:To = "cuenta_para@gmail.com" 
 oMsg:From ="cuenta_de@gmail.com"
 oMsg:Subject = Asunto
 oMsg:HTMLBody = Cuerpo
 If !Empty(Adj)
   If File(Adj)
    oMsg:AddAttachment(Adj)
   Endif
 Endif
 oMsg:Configuration = oConf

 oMsg:Send()

CATCH oError
 MsgInfo("No pudo enviar el correo: " + oError:Description, "Error..." )
  lOk:=.F.
END

Return lOk
Saludos,



Adhemar C.
Posts: 150
Joined: Tue Jul 15, 2008 07:12 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Wed Jan 27, 2021 01:12 PM
asi hago yo, y salen automaticamente los emails

Code (fw): Select all Collapse
//-----------------------------------------------------------------------------------------------
Function GMAILBK (cDestino,cAsunto,cTexto,cAdjunto )

Local oEmailCfg,oEmailMsg,oError,cHtml

Local cServer:= GetPvProfString("Enviador","SERVERSTP" ,"", cIniFile)
Local nPortEmail:=VAL(GetPvProfString("Enviador","EMAILPUERTO","25", cIniFile))
Local cEmailFrom:=GetPvProfString("Enviador","EMAILFROM" ,"", cIniFile)
Local cEmailUser:=GetPvProfString("Enviador","EMAILUSER" ,"", cIniFile)
Local cEmailPass:=GetPvProfString("Enviador","EMAILPASSW" ,"", cIniFile)
Local cEmailSsl:=GetPvProfString("Enviador","EMAILSSL" ,"NO", cIniFile)

DEFAULT cAdjunto:=""
DEFAULT cAsunto :=""
DEFAULT cTexto := ""

if Empty(cDestino )
msgAlert("no ha puesto un destinatario")
Return .f.
endif

TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer //"smtp.fibertel.com.ar" //"smtp.live.com" ///"smtp.gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := nPortEmail //25 //465
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.
if cEmailSsl='SI'
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .T. //para ssl
else
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .F. //para sin ssl
endif
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cEmailUser //
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cEmailPass //
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
:Update()
END WITH
CATCH oError
MsgInfo( "No se ha enviado el " + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
END
oError:=NIL

TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration = oEmailCfg
:From = chr(34)+Empresa+' '+chr(34) + '<'+cEmailFrom+'>' // This will be displayed in the From (The email id does not appear)
:To = cDestino
:Subject = cAsunto
:MDNRequested = .T.
:TextBody = cTexto
if !Empty(cAdjunto)
:AddAttachment(cAdjunto)
endif

END WITH
oEmailMsg:Send()
CATCH oError
MsgInfo("No se ha enviado el mensaje" + ";" + CRLF+ ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
"OSCode: "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
"Message: " + oError:Description )
END

// MsgInfo("Correo enviado correctamente")

Return .T.
//-----------------------------------------------------------------------------------------------
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Wed Jan 27, 2021 01:27 PM
postinelli wrote:asi hago yo, y salen automaticamente los emails

Code (fw): Select all Collapse
//-----------------------------------------------------------------------------------------------
Function GMAILBK (cDestino,cAsunto,cTexto,cAdjunto )

Local oEmailCfg,oEmailMsg,oError,cHtml

Local cServer:= GetPvProfString("Enviador","SERVERSTP" ,"", cIniFile)
Local nPortEmail:=VAL(GetPvProfString("Enviador","EMAILPUERTO","25", cIniFile))
Local cEmailFrom:=GetPvProfString("Enviador","EMAILFROM" ,"", cIniFile)
Local cEmailUser:=GetPvProfString("Enviador","EMAILUSER" ,"", cIniFile)
Local cEmailPass:=GetPvProfString("Enviador","EMAILPASSW" ,"", cIniFile)
Local cEmailSsl:=GetPvProfString("Enviador","EMAILSSL" ,"NO", cIniFile)

DEFAULT cAdjunto:=""
DEFAULT cAsunto :=""
DEFAULT cTexto := ""

if Empty(cDestino )
msgAlert("no ha puesto un destinatario")
Return .f.
endif

TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer //"smtp.fibertel.com.ar" //"smtp.live.com" ///"smtp.gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := nPortEmail //25 //465
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.
if cEmailSsl='SI'
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .T. //para ssl
else
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .F. //para sin ssl
endif
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cEmailUser //
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cEmailPass //
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
:Update()
END WITH
CATCH oError
MsgInfo( "No se ha enviado el " + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
END
oError:=NIL

TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration = oEmailCfg
:From = chr(34)+Empresa+' '+chr(34) + '<'+cEmailFrom+'>' // This will be displayed in the From (The email id does not appear)
:To = cDestino
:Subject = cAsunto
:MDNRequested = .T.
:TextBody = cTexto
if !Empty(cAdjunto)
:AddAttachment(cAdjunto)
endif

END WITH
oEmailMsg:Send()
CATCH oError
MsgInfo("No se ha enviado el mensaje" + ";" + CRLF+ ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
"OSCode: "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
"Message: " + oError:Description )
END

// MsgInfo("Correo enviado correctamente")

Return .T.
//-----------------------------------------------------------------------------------------------


Mui bién. Cuasi perfecto.

Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Thu Jan 28, 2021 03:01 PM

Hola amigos,,,

Gracias Adhemar,
Gracias Postinelli,
Gracias Joao

Voy a probar estas sugerencias que me dan y les estare avisando por acá

seguimos en contacto

"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Sun Jan 31, 2021 10:37 PM

Hola de nuevo..

Adhemar, funciono perfecto, muchisimas gracias por la ayuda.
Postinelli, tambien funciono a la primera.. agradecido por tu atencion.

Resuelto el problema que tenia.

Victor, gracias tambien por tu colaboracion y soporte.

Gracias al foro FW !!

"Los errores en programación, siempre están entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: ¿Alguna funcion para enviar email desatendido xHarbour?
Posted: Mon Feb 01, 2021 03:30 AM

Rick:

Thank you.

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero

Continue the discussion