Tim
I am not a big fan of sending e-mail from a client computer .. just too many variables, too many different operating systems, too many different clients e-mail ... Outlook Express, Live mail, Outlook ( from office ) or Thunderbird ..
I have found that using CDO is the most reliable solution that does not need to use any specific e-mail client on a machine .. to send messages to a gmail account I monitor. With Gmail you have to change your Gmail settings to use un-secure devices, otherwise CDO and g-mail work fairly well.
Here is the CDO code I have had the best results using ..
Rick Lipkin
//---------------------------------------------
Function _SendMail(cSmtp_Host,nPort,lSsl,;
cSmtp_UserId,cSmtp_Password,cFrom,cTo,aCC,cSubject,cMessage,oDlg)
Local oEmailCfg,oErr,lFailed,oEmailMsg,cAddress,i
*msginfo( "External" )
*msginfo( cSmtp_host )
*msginfo( nPort )
*msginfo( lssl )
*msginfo( cSmtp_UserId )
*msginfo( cSmtp_Password )
*msginfo( "Cfrom "+cFrom )
*msginfo( cTo )
*xbrowse(aCC)
*msginfo( cSubject )
SysReFresh()
// smtpauthenticate
// 0 cdoAnonymous Perform no authentication.
// 1 cdoBasic Use the basic (clear text) authentication mechanism.
// 2 cdoNTLM Use the NTLM authentication mechanism.
// sendusing
// Remote SMTP = 2, local = 1
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
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cSmtp_Host
: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 := 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := lSsl
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cSmtp_Userid
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cSmtp_Password
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 15
:Update()
END WITH
CATCH oError
MsgInfo( "Error in Configuration" )
END
oError := NIL
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration = oEmailCfg
:From := cFrom //"me@bogus.com"
:To := cTo
:CC := cAddress
// :CC := ""
: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)