Dear All,
Can a FW App able to send email but the user's PC has no SMTP?
Thanks.
Frances
Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
Dear All,
Can a FW App able to send email but the user's PC has no SMTP?
Thanks.
Application
===========
Path and name: D:\b\mio\email\email.exe (32 bits)
Size: 1,744,384 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6406)
FiveWin Version: FWHX 12.03
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 03/02/15, 22:18:33
Error description: Error CDO.Message/3 DISP_E_MEMBERNOTFOUND: SEND
Args:
Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:SEND( 0 )
Called from: email.prg => MAIN( 27 )
Can try looking into Blat
//-------------------------------------------------------------------------------
METHOD SendUsingCDO() CLASS TMpMail
LOCAL oEmailMsg, oErr
LOCAL cSchema := "http://schemas.microsoft.com/cdo/configuration/"
LOCAL cFile
LOCAL lFailed := .F.
::cCopyTo := ""
IF ::aCopyTo # NIL .AND. !EMPTY( ::aCopyTo )
AEVAL( ::aCopyTo, { |e| ::cCopyTo+= ALLTRIM( e ) + ";" } )
ENDIF
IF !EMPTY( ::aSendTo ) .AND. LEN( ::aSendTo ) > 0 //.AND. EMPTY( ::cEMailAddress )
::cEMailAddress := ""
AEVAL( ::aSendTo, { |e| ::cEMailAddress += ALLTRIM( e ) + ";" } )
ENDIF
::cEMailAddress := LEFT( ::cEMailAddress, LEN( ::cEMailAddress )-1 )
::logDebugInfo()
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:From := ALLTRIM( ::cFromEMail )
:To := ::cEMailAddress
:CC := ::cCopyTo
:BCC := ""
:Subject := ALLTRIM( ::cSubject )
:TextBody := ::cBody
FOR EACH cFile IN ::aAttachedfiles
:AddAttachment( ALLTRIM( cFile ) )
NEXT
WITH OBJECT :configuration:Fields
:Item( cSchema + "smtpserver" ):Value := ALLTRIM( ::cSmtpHost )
:Item( cSchema + "smtpserverport" ):Value := ::nSmtpPort
:Item( cSchema + "sendusing" ):Value := iif( ::isRemoteSMTP, 2, 1 )
:Item( cSchema + "smtpauthenticate" ):Value := ::lSMTPAuth
:Item( cSchema + "smtpusessl" ):Value := ::lUseSSL
:Item( cSchema + "sendusername" ):Value := ALLTRIM( ::cUserName )
:Item( cSchema + "sendpassword" ):Value := ALLTRIM( ::cUserPasswrd )
:Item( cSchema + "smtpconnectiontimeout"):Value := ::nTimeOut
:Update()
END WITH
:Send()
END
CATCH oErr
WriteErrorLog( oErr )
lFailed := .t.
IF ::bSMTPFail != NIL ;EVAL( ::bSMTPFail, SELF ) ;ENDIF
END
IF ::bSMTPDone != NIL ; EVAL( ::bSMTPDone, SELF ) ;ENDIF
RETURN lFailedMarcelo;
Hola, siempre es grato saber de ti. Espero sigas bien.
You always get this same "generic" error when any of the CDO parameters is not right (or just perfect). Try my code above. Make sure you have all the correct parameters aligned. If it doesn't work just write a self-contained reduced fw sample that we can share and work together. Let me know how it works for you. I'll be glad to help.
Reinaldo.
LOCAL cSchema := "http://schemas.microsoft.com/cdo/configuration/"Dear All,
BTW, the FW App installed in PC without internet access, no email client installed. Just the FW App but with access to LAN with internal SMTP.
Thanks for the help.
#include "fivewin.ch"
FUNCTION main()
LOCAL oEmailMsg, oErr
LOCAL cSchema := "http://schemas.microsoft.com/cdo/configuration/"
LOCAL cFile
LOCAL lFailed := .F.
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:From := "cartekbackup@gmail.com"
:To := "marcelo.via@gmail.com"
:CC := ""
:BCC := ""
:Subject := "TEST"
:TextBody := "CUERPITO"
WITH OBJECT :configuration:Fields
:Item( cSchema + "smtpserver" ):Value := "smtp.google.com"
:Item( cSchema + "smtpserverport" ):Value := 465 //586
:Item( cSchema + "sendusing" ):Value := 2
:Item( cSchema + "smtpauthenticate" ):Value := .T.
:Item( cSchema + "smtpusessl" ):Value := .T.
:Item( cSchema + "sendusername" ):Value := "login"
:Item( cSchema + "sendpassword" ):Value := "password"
:Item( cSchema + "smtpconnectiontimeout"):Value := 30
:Update()
END WITH
:Send()
END
RETURN NIL :From := "reinaldo.crespo@gmail.com"
...
WITH OBJECT :configuration:Fields
:Item( cSchema + "smtpserver" ):Value := "smtp.gmail.com"
:Item( cSchema + "sendusername" ):Value := "reinaldo.crespo@gmail.com"
:Item( cSchema + "sendpassword" ):Value := "MySecretPassword"
...//-------------------------------------------------------------------------------------
METHOD SendUsingSMTP() CLASS TMpMail
LOCAL oMail,oErr
LOCAL bEnd := { || IF( oMail # NIL, oMail:End(), ), oMail := NIL }
LOCAL aSendTo := ::aSendTo
IF EMPTY( aSendTo ) ;aSendTo := HB_ATOKENS( ::cEMailAddress, IIF( AT( ::cEMailAddress, ";" ) > 0, ";", "," ) ) ;ENDIF
oMail := TSmtp():New( ::cIp, ::nSmtpPort, ::lSMTPAuth, ::cUserName, ::cUserPasswrd )
oMail:lTxtAsAttach := .F. // .T. forces text files as attachments, not inline
oMail:cReplyTo := ::cFromEMail
oMail:nGMT := TimeZone() //-5 // Atlantic Standard Time (GMT -05:00)
oMail:oSocket:lDebug := ::lSMTPDebug
oMail:oSocket:cLogFile := "smtp.log"
oMail:nDelay := ::nTimeOut
::LogDebugInfo()
oMail:bDone := { || IIF( ::bSMTPDone != NIL , EVAL( ::bSMTPDone, oMail ), ),;
;//AEVAL( oMail:aAttachments, { |e| ferase( e ) } ),;
Logfile( "smtp.log", { "Done event fired" } ),;
EVAL( bEnd ) }
oMail:bFailure := { || ;
IIF( oMail != Nil .AND. oMail:oSocket:lDebug, ;
Logfile( oMail:oSocket:cLogFile, ;
{ "Failure to send email. Status = " + cValToChar( oMail:nStatus ) + CRLF + ;
oMail:cError + CRLF +;
"lAuth = " + cValToChar( oMail:lAuth ) + CRLF +;
"lDoAuth = " + cValToChar( oMail:lDoAuth ) + CRLF +;
"cUser = " + oMail:cUser + CRLF + ;
"cFrom = " + oMail:cFrom + CRLF + ;
"cPassword = " + oMail:cPassword } ), ),;
IIF( ::bSMTPFail != NIL , EVAL( ::bSMTPFail, oMail ), ),;
EVAL( bEnd ) }
oMail:bConnecting := { || iif( oMail:oSocket:lDebug,;
logfile( oMail:oSocket:cLogFile, {"Connecting to SMTP server " + ::cIp } ), ) }
oMail:bConnected := { || iif( oMail:oSocket:lDebug, ;
( logfile( oMail:oSocket:cLogFile, { "Sending eMail Via " + ::cSmtpHost, oMail:cError } ),;
logfile( oMail:oSocket:cLogFile, aSendTo ) ), ) }
oMail:SendMail( ::cFromEMail , aSendTo, ::cBody, ::cSubject, ::aAttachedfiles, ::aCopyTo ,, .F. )
RETURN NIL//---------------------------------------------
Function _SendMail(cSmtp_Host,nPort,lSsl,;
cSmtp_UserId,cSmtp_Password,cFrom,cTo,aCC,cSubject,cMessage,oDlg)
Local oEmailCfg,oErr,lFailed,oEmailMsg,cAddress,i
*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. // request acknowledgement
:TextBody := cMessage
* for each cFile in ::aFiles
* :AddAttachment( cfile )
* next
:Fields:update()
:Send()
// ? "[ "+Time()+" ] Mail Sent :"+ ::email
END
CATCH oError
MsgINfo("Error in sending e-mail:"+ oError:Description )
lFailed := .t.
END
oEmailCfg := NIL
oEmailMsg := NIL
oDlg:End()
SysRefresh()
Return(lFailed)Dear Reinaldo,
thanks very much, I can see my mistakes, the sample work ok
best regards
Marcelo