added additional logging to try and capture the root cause of email service critical mona alerts
This commit is contained in:
parent
d5514bc3ca
commit
3d1f096f80
@ -41,32 +41,40 @@ Return Response or ""
|
||||
|
||||
Service SendEmail(FromAddress, ToAddress, Subject, Body)
|
||||
|
||||
If ( (FromAddress NE '') and (ToAddress NE '') ) then
|
||||
ErrorMessage = ''
|
||||
If ( (FromAddress NE '') and (ToAddress NE '') ) then
|
||||
ErrorCode = ''
|
||||
EmailServer = Environment_Services('GetIfxEmailServer')
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
MailDll = DotNetDir:'System.dll'
|
||||
Set_Property.Net(DotNetHandle, "AssemblyName", MailDll)
|
||||
If Not(Get_Status(ErrorMessage)) then
|
||||
If Not(Get_Status(ErrorCode)) then
|
||||
Params = FromAddress:@FM:ToAddress:@FM:Subject:@FM:Body
|
||||
ParamTypes = 'System.String':@FM:'System.String':@FM:'System.String':@FM:'System.String'
|
||||
objEmailMessage = Create_Class.Net(DotNetHandle, "System.Net.Mail.MailMessage", 0, Params, ParamTypes)
|
||||
If Not(Get_Status(ErrorMessage)) then
|
||||
If Not(Get_Status(ErrorCode)) then
|
||||
objEmailClient = Create_Class.Net(DotNetHandle, "System.Net.Mail.SmtpClient", 0, EmailServer, 'System.String')
|
||||
If Not(Get_Status(ErrorMessage)) then
|
||||
If Not(Get_Status(ErrorCode)) then
|
||||
rv = Send_Message.Net(objEmailClient, 'Send', objEmailMessage, 'RevDotNet', 0)
|
||||
If Get_Status(ErrorMessage) then Null
|
||||
If Get_Status(ErrorCode) then ErrorMessage = 'Error in ':Service:' service. Get_Status response: ':ErrorCode
|
||||
Free_Class.Net(objEmailClient)
|
||||
end else
|
||||
ErrorMessage = 'Error in ':Service:' service. Get_Status response: ':ErrorCode
|
||||
end
|
||||
Free_Class.Net(objEmailMessage)
|
||||
end else
|
||||
ErrorMessage = 'Error in ':Service:' service. Get_Status response: ':ErrorCode
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error in ':Service:' service. Get_Status response: ':ErrorCode
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error in ':Service:' service. Null FromAddress or ToAddress passed into service.'
|
||||
end
|
||||
Response = (ErrorMessage EQ '')
|
||||
|
||||
If ErrorMessage NE '' then Error_Services('Add', ErrorMessage)
|
||||
Response = (ErrorMessage EQ '')
|
||||
|
||||
End Service
|
||||
|
||||
|
@ -35,7 +35,7 @@ LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\EmailService'
|
||||
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' EmailService.csv'
|
||||
Headers = 'Logging DTM' : @FM : 'Error'
|
||||
Headers = 'Logging DTM' : @FM : 'LogData'
|
||||
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$)
|
||||
|
||||
ErrTitle = 'Error in Stored Procedure "obj_Notes"'
|
||||
@ -360,14 +360,13 @@ ForwardEMail:
|
||||
Lock hSysLists, ServiceKeyID then
|
||||
rv = Set_Status(0)
|
||||
RList('SELECT EMAIL_BOX BY NOTE_KEY', 5, '', '', '')
|
||||
Done = 0
|
||||
Done = False$
|
||||
LOOP
|
||||
ReadNext eMailBoxKey else Done = 1
|
||||
ReadNext eMailBoxKey else Done = True$
|
||||
UNTIL Done
|
||||
mbParms = 'EMAIL_BOX':@RM:eMailBoxKey
|
||||
eMailBoxRec = obj_Tables('ReadRec',mbParms)
|
||||
If @File_Error EQ '' then
|
||||
|
||||
eMailAddr = eMailBoxRec<EMAIL_BOX_EMAIL_ADDR$>
|
||||
eMailText = eMailBoxRec<EMAIL_BOX_EMAIL_TEXT$>
|
||||
eMailHeader = eMailBoxRec<EMAIL_BOX_EMAIL_HEADER$>
|
||||
@ -377,11 +376,15 @@ ForwardEMail:
|
||||
IF OISentFrom = 'OI_ERROR' THEN SendTo := XLATE('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
|
||||
Success = Email_Services('SendEmail', SentFrom, SendTo, eMailHeader, eMailText)
|
||||
If Success then
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDtm
|
||||
LogData<2> = 'Successfully sent email From: ':SentFrom:' To: ':SendTo:' Header: ':eMailHeader:' Body: ':eMailText
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
Mona_Services('SendBufferedStatus', 'OPENINSIGHT_MES_OP_FE', 'Email-Service', 'ok')
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDtm
|
||||
LogData<2> = Error_Services('GetMessage')
|
||||
LogData<2> = 'Failed to send email From: ':SentFrom:' To: ':SendTo:' Header: ':eMailHeader:' Body: ':eMailText:' Error message: ':Error_Services('GetMessage')
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
Mona_Services('SendBufferedStatus', 'OPENINSIGHT_MES_OP_FE', 'Email-Service', 'critical')
|
||||
end
|
||||
@ -643,4 +646,3 @@ BulkCreate:
|
||||
|
||||
RETURN
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user