hola anexo la funcion completa
***************************************************************
* Enviando emails 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
* 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
* Desenvolvedor: Ricardo de Moura Marques 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
* email: ricardomouramarques@hotmail.com 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽*
* 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
* Agradecimentos ao Alessandro Seribeli Barreto - "Ale SB" 聽 聽*
* pelo c贸digo inicial, sem o qual, esse projeto 聽 聽 聽 聽 聽 聽 聽 *
* n茫o seria poss铆vel 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
* 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 *
***************************************************************
#include "fivewin.ch"
memvar correo
Static cAttach := ""
Static aAttach := {}
********************************************************************************
Function Main()
local cdestino :="chino72vale@hotmail.com;ferropuerto@ferropuerto.com"
local carchivos:={"C:\fwh\samples\hola.txt","C:\fwh\samples\texto.txt"}
local ctxt 聽 聽 :="a mandar un correo"
local csubject :="correo de pruebas "
local cbmp 聽 聽 :="c:\faceleben\kasto2.bmp"
local chtml 聽 聽:="c:\faceleben\suave.html"
聽 if config_email(cdestino, carchivos, ctxt, csubject,cbmp,chtml)
聽 聽 聽 ? "se mando el correo"
聽 else
聽 聽 聽? " no se mando correo"
聽 endif
聽
Return Nil
********************************************************************************
Function Config_eMail(cdest, cfiles, ctxt, csubject, cbmp, chtml )
聽 Local cUser,cPass,cRemt, cCC, cCCO
聽 local lRet := .f.
聽 local oCfg, oError
聽 local cServ :="smtp.xxxxx.com" 聽 聽 聽 聽 // servidor smtp
聽 local nPort :=25 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// puerto
聽 local lAut 聽:=.t.
聽 local lSSL 聽:=.f. 聽 聽 聽
聽
聽
聽 if cfiles=nil
聽 聽 聽aAttach:={}
聽 else
聽 聽 聽aAttach:=cfiles
聽 endif 聽
聽
聽
聽 cPass:="xxxxxx" 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽//usuario 聽
聽 cuser:="xxxxx@xxxxx.com" 聽 聽 聽 聽 聽 聽 //correo del quien manda
聽 ccc:=""
聽 ccco:=""
聽 cRemt:=cuser
聽
聽
聽// aAttach:=CFILES 聽 // serian los archivos anexados we
聽
聽 if Empty(cPass) .or. Empty(cRemt) .or. empty(cDest)
聽 聽 聽? "falta datos para mandar correo,,,, destino/ remitente / usuario checar "
聽 聽 聽return .f.
聽 endif 聽
聽 ? "entramos a la configucraion"
聽 TRY
聽 聽 oCfg := CREATEOBJECT( "CDO.Configuration" )
聽 聽 聽 WITH OBJECT oCfg:Fields
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" 聽 聽 聽 ):Value := cServ
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" 聽 ):Value := nPort
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" 聽 聽 聽 聽):Value := 2
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := lAut
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" 聽 聽 聽 ):Value := lSSL
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" 聽 聽 ):Value := cUser
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" 聽 聽 ):Value := cPass
聽 聽 聽聽 聽聽 聽 聽 :Update()
聽 聽 聽 END WITH
聽 聽 聽 lRet := .t.
聽 CATCH oError
聽 聽 MsgInfo( "No se pudo enviar e-Mail!" 聽+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+ ;
聽 聽 聽 聽 聽 聽 聽"Mensaje: " 聽 + oError:Description, "Atenci贸n" )
聽 END
聽 //--> FIM DAS CONFIGURA脟OES.
聽 if lRet
聽 聽 聽lRet := Envia_eMail(oCfg,cRemt,cDest, cCC, cCCO, cTxt, cSubject, cbmp, chtml)聽 聽
聽 endif
聽 聽
Return lRet
聽
********************************************************************************
Function Envia_eMail(oCfg,cFrom, cTo, cCC, cBCC, cMsg, cSubject, cbmp, chtml)
聽
聽 local cToken
聽 local lRet := .f. , Omsg , x, i, loBP
聽聽 聽
聽 聽 聽 聽TRY
聽 聽 聽 聽 聽oMsg := CREATEOBJECT ( "CDO.Message" )
聽 聽 聽 聽 聽 聽WITH OBJECT oMsg
聽 聽 聽 聽 聽 聽 聽 聽 :Configuration = oCfg
聽 聽 聽 聽 聽 聽 聽 聽 :From = cFrom 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 :To = cTo
聽 聽 聽 聽 聽 聽 聽 聽 :CC = cCC
聽 聽 聽 聽 聽 聽 聽 聽 :BCC = cBCC
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 :Subject = cSubject
聽 聽 聽 聽 聽 聽 聽 聽 :TextBody = cMsg
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 For x := 1 To Len( aAttach )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if aAttach[x] <> NIL
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽:AddAttachment(AllTrim(aAttach[x]))
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 Next
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 :HTMLBody = "<p><img src='cid:id_imagen10'></p>" +"<p>La imagen de arriba esta embebida en el mensaje.</p>"
聽 聽 聽 聽 聽 聽 聽 聽 loBP:=:AddRelatedBodyPart(cbmp, "id_imagen10", 1)
聽 聽 聽 聽 聽 聽 聽 聽 WITH OBJECT loBP:Fields
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 :Item("urn:mailheader:Content-ID")= "id_imagen10"
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 :Update()
聽 聽 聽 聽 聽 聽 聽 聽 END WITH
聽 聽 聽 聽 聽 聽 聽 聽 :CreateMHTMLBody("File://"+chtml,0)
聽 聽 聽 聽 聽 聽 聽 聽 :Send()
聽 聽 聽 聽 聽 聽END WITH
聽 聽 聽 聽 聽 聽lRet := .t.
聽 聽 聽 聽CATCH
聽 聽 聽 // 聽 聽 MsgInfo("No se pudo mandar la factura ")
聽 聽 聽 聽 聽 聽lRet := .f.
聽 聽 聽 聽 聽END
聽
聽 聽
Return lRet
se llama la funcion
config_email(cdestino, carchivos, ctxt, csubject,cbmp,chtml)
compilado con xharbour 1.2.1
Benjamin Casarrubias Moreno
Cd. Obreg贸n, Sonora, M茅xico
chino72vale@hotmail.com
Fivewin 24.04, Harbour 3.3, xharbour 1.2.1, Fivelinux, Visual Estudio 2022
Oracle Api Rest, SDK Contpaq, Facturaci贸n Electr贸nica, XML DIOT 2025