Error tracking and emailing

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Error tracking and emailing

#1 Post by rdonnay »

eXpress++ has always included a sample program in \exp19\samples\tracker which shows how to save error information to a database and also email the error info to the programming team.

Over the years, I have modified this system for different customers to include more information about the application and different options for how emails are sent.

I am polling eXpress++ users to find out if you are satisfied with your error tracking system and what other needs do you have.

I helped Bobby Drakos implement a system that captures the screen and attaches it to the error email.
Also, it includes a sendmail.exe service that spools out the emails so the application does not require a direct connection to a mail server. This is the most reliable system yet. Now, with Xbase++ 2.0, the smtp mail client can make a SSL connection to GMAIL as the smtp server. No more need for Marshallsoft or Stunnel to do this.

I would like your feedback about this.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Error tracking and emailing

#2 Post by skiman »

Hi Roger,

I'm using Marshallsoft to send a mail with the info I need. I had a screencapture before, but since Windows 7 the result of this is a black rectangle.

When an error happens in my application, the user can enter what he/she was doing, and then the mail is send. A modified errorsys creates a ZIPfile with the info I need, and it is send as an attachment.

It would be nice if this could work without the Marshallsoft lib. And the mail could be send via Gmail. Would this also work with Office365?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Error tracking and emailing

#3 Post by rdonnay »

Chris -

We have no problem with capturing the screens under all operating systems. There are over 350 workstations.
The below code is in ERRORSYS.PRG. The error info is saved in a database named SENDMAIL.DBF with a field named ATTACHMENT for the screen file. The service then sends out the email.

Code: Select all

DirMake( DC_CurPath() + '\ErrorScreens\' )
cFileName := DC_CurPath() + '\ErrorScreens\' + Dtos(Date())+Strtran(Time(),':','') + '.Jpg'

oWindow := TL_MainWindow()  // a pointer to the main dialog window

DC_Scrn2ImageFile( oWindow, cFileName, XBPBMP_FORMAT_JPG )
The Sendmail() function in the service looks like the below code.
GMAIL requires the following:
cSMTPServer := 'smtp.gmail.com'
nSMTPPort := 465

Code: Select all

FUNCTION SendMail( cSMTPServer, cSender, cRecipient, cSubject, ;
                          cReplyTo, cAttachment, cText, cErrorText )

LOCAL oMail, oSender, oRecipient, oSmtp, lError := .t., cPrefix, ;
      cUserID, cPassword, cIniFile, nSMTPPort, aRef, aData

DEFAULT cSMTPServer := "donnay-software.com", ;
        cSender := 'rogerdonnay@donnay-software.com', ;
        cRecipient := 'rogerdonnay@donnay-software.com'

aRef := { ;
  'SMTPServer', ;
  'SMTPPort', ;
  'UserID', ;
  'Password' }

aData := { ;
  Space(40), ;
  0, ;
  Space(40), ;
  Space(20) }

DC_IniLoad('C:\Sendmail.Ini','EMAIL',aData,aRef)

cSMTPServer := Alltrim(aData[1])
nSMTPPort := aData[2]
cUserID := Alltrim(aData[3])
cPassword := Alltrim(aData[4])

IF Empty(cSMTPServer)
  cErrortext := 'No SMTP Server Address'
ELSEIF Empty(cSender)
  cErrorText := 'No Sender Address'
ELSEIF Empty(cRecipient)
  cErrorText := 'No Recipient Address'
ELSEIF Empty(cSubject)
  cErrortext := 'No Subject'
ELSE
  lError := .f.
ENDIF
IF lError
  RETURN .f.
ENDIF

oMail      := MIMEMessage():new()
oSender    := MailAddress():new( Alltrim(cSender) )
oRecipient := MailAddress():new( Alltrim(cRecipient) )

// Assemble the e-mail
oMail:setFrom( oSender     )
oMail:setSubject( Alltrim(cSubject) )

oMail:setMessage( cText )
oMail:addRecipient( oRecipient  )
IF !Empty(cReplyTo)
  oMail:addHeader( "Reply-To", Alltrim(cReplyTo) )
ENDIF
oMail:setContentType('text/html')

IF !Empty(cAttachment)
  oMail:attachFile( cAttachment  )
ENDIF

oSmtp := SMTPClient():new( Alltrim(cSMTPServer), nSMTPPort, 'donnay-software.com' )

IF oSmtp:connect(cUserId,cPassword)
  IF !oSmtp:send( oMail )
    cErrorText := 'Unable to send message - Cause unknown'
  ENDIF
  oSmtp:disconnect()
  lError := .f.
ELSE
  cErrorText := "Unable to connect to mail server"
ENDIF

IF !Empty(cErrorText)
  WTL cErrorText
ENDIF

RETURN !lError
The eXpress train is coming - and it has more cars.

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Error tracking and emailing

#4 Post by skiman »

Thanks for the code. I will try this.
Best regards,

Chris.
www.aboservice.be

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Error tracking and emailing

#5 Post by RDalzell »

Roger,

I found your DbNotify() very interesting.

I have been unable to determine how to perform the call upon certain desired events, perhaps updating the docs would be beneficial.

Rick

Post Reply