Options

How to send an Email automatically when a JOB encounters an error?

Ashu8Ashu8 Member Posts: 14
Hello Experts,

How to send an Email automatically when a JOB encounters an error? Here I have created a codeunit which runs the report through JOB after every 24 hours. How can I automate the Email sending if it encounters any error. What code or trigger has to be written to get this functionality. Please suggest!

Answers

  • Options
    RockWithNAVRockWithNAV Member Posts: 1,139
    You need to manipulate your code for this!!
  • Options
    Ashu8Ashu8 Member Posts: 14
    Can you suggest how?
  • Options
    KTA8KTA8 Member Posts: 389
    I think it should be done in codeunit 448; getnextrequest function, if JobQueueEntry.Status::Error -> mail
  • Options
    erolionerolion Member Posts: 2
    You can write the below function and call from the function from Table 472: Job Queue Entry - Function : "SetErrorMessage"

    A new function to send an email as:

    eMailNotification(ToName : Text[80];CCName : Text[80];BCCName : Text[80];Subject : Text[250];Body : Text[250];AttachFileName : Text[260];OpenDialog : Boolean)

    SMTPSetup.GET;
    SMTPMail.CreateMessage(SMTPSetup."Email Sendor Name", SMTPSetup."Email Sendor Email",
    ToName, Subject, '', TRUE);
    SMTPMail.AddCC(CCName);
    SMTPMail.AddBCC(CCName);
    SMTPMail.AppendBody(Body);
    SMTPMail.AppendBody('<BR><BR>');
    SMTPMail.AppendBody('<HR>');
    SMTPMail.AppendBody('This is an automatically generated mail by NAV');
    SMTPMail.Send;
Sign In or Register to comment.