CDO email

Post Reply
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

CDO email

Post by Wanderson »

Hi, I try to send email using CDO but sometimes send and sometimes not, what I do wrong?
Thanks

local lRet := .f.
local oCfg, oError

local cServ := "smtp.rotamaxgroup.com"
local nPort := "587"
local lAut := .t.
local lSSL := .f.
local cPass := "XXXXXX"


cUser := Alltrim(_cUser)
cRemt := Alltrim(_cUser)

TRY
oCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/config ... smtpserver" ):Value := cServ
:Item( "http://schemas.microsoft.com/cdo/config ... serverport" ):Value := nPort
:Item( "http://schemas.microsoft.com/cdo/config ... /sendusing" ):Value := 2
:Item( "http://schemas.microsoft.com/cdo/config ... thenticate" ):Value := lAut
:Item( "http://schemas.microsoft.com/cdo/config ... smtpusessl" ):Value := lSSL
:Item( "http://schemas.microsoft.com/cdo/config ... ndusername" ):Value := cUser
:Item( "http://schemas.microsoft.com/cdo/config ... ndpassword" ):Value := cPass
:Update()
END WITH
lRet := .t.
CATCH oError
MsgInfo( "Não Foi possível Enviar o 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, "Atenção" )
END

////////////////////////

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( cAttach )
if cAttach[x] <> NIL
:AddAttachment(cAttach[x])
endif
Next
:Send()
END WITH
lRet := .t.
CATCH
// MsgInfo("Não foi possível enviar a mensagem")
lRet := .f.
END
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: CDO email

Post by Silvio.Falconi »

use alltrim( -- values -- )
for each values you pass to cdo
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: CDO email

Post by Wanderson »

Silvio.Falconi wrote:use alltrim( -- values -- )
for each values you pass to cdo
Thanks Silvio I Will Try.
Post Reply