I am trying to trap an SMTP ( tsntp class ) error when I have a message that failed to send... generally because of a bad email address ..
Here is my code .. where do I need to place my try, catch, end try ?? it does not work where you see it now ??
Rick Lipkin
- Code: Select all Expand view RUN
lFAIL := .F.
oWndMdi:SetMsg( "Sending Reporting noticication to "+cTO )
WSAStartup()
oOutMail := TSmtp():New( cIP := GetHostByName( cHOST ) )
oOutMail:bConnecting = { || oWndMdi:SetMsg( "Connecting to "+cHOST ) }
oOutMail:bConnected = { || oWndMdi:SetMsg( "Connected" ) }
oOutMail:bDone = { || oWndMdi:SetMsg( "Message sent successfully" ) }
TRY
oOutMail:SendMail( cFROM,; // From
{ cTO },; // To
cMESSAGE,; // Msg Text
cSUBJECT,;
{"C:\DBTMP\PROJINFO.BAT"},; // attachment
aCC, ; // cc array
{ }, ; // bc
.F., ; // no return receipt
NIL ) // not html
CATCH oERR
lFAIL := .T.
END TRY
IF lFAIL = .T.
cSUBJECT := "Email Error FAILED to be Sent"
MsgInfo( cSUBJECT )
ENDIF
SysReFresh()