I have been trying to use CDO to send SMTP e-mail from a Project Management application I am writing. I have created a Gmail account and I use Rafa's CDO code mentioned in the Spanish forum... and I have been successful. Unfortunately, when I login to a different network or location ( other than the location\Network that created the Gmail account ) the CDO e-mail fails every time.
I am just curious ... I have the same code that runs flawlessly from my office ( location and IP where I created the gmail account ) .. has anyone experienced this behavor in any applications they are currently using ?
To clarify .. I am using gmail as an SMTP relay to distribute my application's e-mail to various Project stakeholders.
Again .. this code runs perfectly from my office ... but if I login to a different network and run the same code .. it fails.
Any Ideas??
Rick Lipkin
- Code: Select all Expand view
//---------------------------------------------
Function _SendMail(cSmtp_Host,nPort,lSsl,;
cSmtp_UserId,cSmtp_Password,cFrom,cTo,aCC,cSubject,cMessage,oDlg)
Local oEmailCfg,oErr,lFailed,oEmailMsg,cAddress,i
SysReFresh()
// smtpauthenticate
// 0 cdoAnonymous Perform no authentication.
// 1 cdoBasic Use the basic (clear text) authentication mechanism.
// 2 cdoNTLM Use the NTLM authentication mechanism.
If empty(aCC)
cAddress := ""
Else
For i = 1 to Len(aCC)
If i = 1
cAddress := aCC[i]
Else
cAddress := cAddress+","+aCC[i]
Endif
Next
Endif
lFailed := .f.
TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields // cSmtp_Host
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cSmtp_Host //::smtpServer
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := nPort //465 //::smtpPort
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 //::sendusing // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := 1 //::AUTH // 0 , 1 ,2
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := lSsl //::SSL
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cSmtp_Userid //::username
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cSmtp_Password
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 15 //::TimerOut
:Update()
END WITH
CATCH oError
MsgInfo( "Error in Configuration" )
END
oError := NIL
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration = oEmailCfg
:From := cFrom
:To := cTo
:CC := cAddress
:BCC := ""
:Subject := cSubject
// :MDNRequested = .T. // Solicitud de reconocimiento, o acuse de recibo
:TextBody := cMessage
* for each cFile in ::aFiles
* :AddAttachment( cfile )
* next
:Fields:update()
:Send()
// ? "[ "+Time()+" ] Enviado correo :"+ ::email
END
CATCH oError
MsgINfo("Error in sending e-mail:"+ oError:Description )
lFailed := .t.
END
oEmailCfg := NIL
oEmailMsg := NIL
oDlg:End()
SysRefresh()
Return(lFailed)