Roger,
You can automate send error file,
I use Blat to this:
Code: Select all
...
// Generates a file with an Error Log
BEGIN SEQUENCE
oOldError = ErrorBlock( { || DoBreak() } )
MemoWrit( "Error.log", cErrorLog )
END SEQUENCE
ErrorBlock( oOldError )
/* PANTALLA DE CONTROL DEL ERROR */
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -10
DEFINE DIALOG oDlg RESOURCE "dlgMSRel"
REDEFINE SAY oSay VAR "O seguinte erro foi encontrado:"+CRLF+" "+TiraErrLixo(ErrorMessage( e ))+CRLF+StackMessage ID 99 OF oDlg COLOR RGB(000,000,000),RGB(255,255,255)
REDEFINE SAY oSay ID 100 OF oDlg COLOR RGB(255,255,255),RGB(000,000,000)
REDEFINE BUTTON oBtn1 ID 1 OF oDlg ;
ACTION Blat( "Cliente: " + M->CL_NOME,;
"smtp.isp.com",;
M->CL_EMAIL,;
"YourEmail@isp.com",;
"***** System Error Message *****",;
"UserName",;
"UserPassword",;
"error.log" )
REDEFINE BUTTON oBtn2 ID 2 OF oDlg ACTION oDlg:End()
REDEFINE BUTTON oBtn3 ID 3 OF oDlg ACTION WAITRUN("NOTEPAD ERROR.LOG") NOBORDER
REDEFINE BUTTON oBtn4 ID 4 OF oDlg ACTION ( lRet := .t., oDlg:End() ) // Retry
REDEFINE BUTTON oBtn5 ID 5 OF oDlg ACTION ( lRet := .f., oDlg:End() ) // Default
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( iif(e:CanRetry,oBtn4:Enable(),oBtn4:Disable()), ;
iif(e:CanDefault,oBtn4:Enable(),oBtn4:Disable()) )
oFont:End()
BEGIN SEQUENCE
oOldError = ErrorBlock( { || DoBreak() } )
/* CONTROL PERSONALIZADO DE ERRORES */
if !lIsDir( "ERRORES" ) //CREAR CARPETA DE ERRORES DEL PROGRAMA
lMkDir( "ERRORES" )
endif
...
Dialog .RC File:
Code: Select all
dlgMSRel DIALOG 20, 28, 245, 138
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Mensagem de Erro"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "&Não enviar", 2, 120, 121, 52, 14
PUSHBUTTON "&Enviar relatório de erros", 1, 4, 121, 114, 14
PUSHBUTTON "Clique aqui.", 3, 188, 96, 55, 14
PUSHBUTTON "&Denovo", 4, 173, 121, 34, 14, WS_DISABLED | WS_TABSTOP
PUSHBUTTON "&Padrão", 5, 209, 121, 34, 14, WS_DISABLED | WS_TABSTOP
LTEXT "Para visualizar os dados contidos neste relatório de erros.", -1, 5, 99, 181, 9
CONTROL "", 100, "static", SS_WHITERECT | WS_CHILD | WS_VISIBLE, -8, -1, 261, 30
ICON "icon_info", -1, 4, 3, 18, 20
LTEXT "Evento de detecção de erros", 99, 28, 3, 224, 24
LTEXT "O programa não responde.", -1, 4, 35, 247, 9
LTEXT "Informe este problema à 5Volution.", -1, 5, 52, 247, 9
LTEXT "Foi criado um relatório detalhando o erro ocorrido que voce pode nos enviar para ajudar a melhorar o 5Volution. Esse relatório será considerado confidencial e anônimo.", -1, 5, 66, 241, 29
GROUPBOX "", -1, -5, 25, 256, 93, BS_GROUPBOX
}
Blat function:
Code: Select all
function blat( cbody ,;
cserver ,;
cto ,;
cf ,;
csubject ,;
cu ,;
cpw ,;
cattach )
BlatCMD := [ blat.txt] + ;
[ -server ] + alltrim(cserver) + ;
[ -to ] + alltrim(cto) + ;
[ -f ] + alltrim(cf) + ;
[ -mailfrom ] + alltrim(cf) + ;
[ -subject "] + alltrim(csubject) + ["] + ;
[ -r ] + ;
[ -u ] + alltrim(cu) + ;
[ -pw ] + alltrim(cpw) + ;
[ -log "email.log" -debug ] + ;
iif( empty( cAttach ),[],[ -attach "] + alltrim(cattach) + ["])
cMacro="BLAT.EXE " + BlatCMD
fErase( "email.log" )
cBody := FormHtml( cSubject, cBody )
memowrit( "blat.txt", cbody )
//memowrit( "blat.bat", cMacro )
WinExec( cMacro, 0 )
if file( "blat.log" )
BlatLOG := memoread( "email.log" )
if "ERROR" $ Upper(BlatLOG)
Mensagem( "Erro: arquivo de BLAT.LOG foi criado" )
return .f.
endif
endif
RETURN .T.
Function FormHtml( cSubject, cBody )
Local cOpen := "", cClose := ""
cHTML := ;
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"' + CRLF + ;
' "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">' + CRLF + ;
'<html>' + CRLF + ;
'<head>' + CRLF + ;
' <title>' + cSubject + '</title>' + CRLF + ;
' <meta http-equiv="Content-Type"' + CRLF + ;
' content="text/html; charset=iso-8859-1">' + CRLF + ;
'</head>' + CRLF + ;
'<body>' + CRLF + ;
cBody + CRLF + ;
'</body>' + CRLF + ;
'</html>'
Return cOpen + cHTML + cClose
On error occurrency, this routine send the email with error.log to you.