Hi All
Is it possible to access email and attachments in a gmail account from a fivewin/xHarbour app.
Cheers
Colin
MsgRun( "Enviando correo, espere...", oApp:EmpresaName, {|| lBorrar := Config_Mail( cUser, cPass, cRemt, cDest, cCC, cCCO,;
cText, cSubject, aTmp, nServ, aServs ) } )
********************************************************************************
Static Function Config_Mail( _cUser, cPass, _cRemt, cDest, cCC, cCCO, cTxt,;
cSubject, aAttach, nServ, aServs )
local lRet := .f.
local oCfg, oError, cUser, cRemt
local cServ := aServs[nServ][2] //--> SERVIDOR SMTP - "smtp.servidor.com.br"
local nPort := aServs[nServ][3]
local lAut := .t.
local lSSL := aServs[nServ][4]
if Empty(cPass) .or. Empty(_cRemt) .or.;
( Empty(cDest) .and. Empty( cCC ) .and. Empty(cCCO) )
Msgstop( "Error en configuracion de la cuenta.", "Atencion" )
return .f.
else
cUser := alltrim(_cUser) + aServs[nServ,1]
cRemt := alltrim(_cRemt) + aServs[nServ,1]
endif
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 fue posible enviar el 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, "Atencion!" )
END
if lRet
lRet := Envia_Mail( oCfg, cRemt, cDest, cCC, cCCO, cTxt, cSubject, aAttach )
endif
Return lRet
********************************************************************************
STATIC Function Envia_Mail( oCfg, cFrom, cTo, cCC, cBCC, cMsg, cSubject, aAttach )
local lRet := .f.
local x, oMsg
/*
cTo := Destinatarios( cTo ) //--> PARA
cCC := Destinatarios( cCC ) //--> COM COPIA
cBCC := Destinatarios( cBCC ) //--> COM COPIA OCULTA
*/
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
// ? cfrom, cto, cCC, cBCC, cSubject, cMsg
:Send()
END WITH
lRet := .t.
CATCH
MsgInfo("No fue posible enviar el mensaje.", "Error." )
lRet := .f.
END
Return lRet
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 77 guests