With IBM HATS, you can create Web applications and Rich client applications that provide an easy-to-use graphical user interface (GUI) for your 3270/5250 applications.
IBM HATS makes it possible to build an application that can scrape data from the host, format it as required, and present the formatted data on an e-mail, programmed to trigger the e-mail automatically on any user action.
To achieve this, the user needs an SMTP server, like Gmail(smtp.gmail.com), Microsoft Outlook(smtp-mail.outlook.com), Yahoo(smtp.mail.yahoo.com), etc.
Let us consider the below HOST screen having a credit report.
First, the user needs to create an IBM HATS macro that extracts the data from the Host screen, for example:
Figure 2: Example Macro extract action.
And then convert the extract into a JSON Array like this:
Figure 3: Example converted JSON Array.
Next, the user can trigger e-mails with the help of popular libraries like Spring Mail.
Below are a few ways to present the host data in the e-mail.
- Using the code below, the user can format it and embed it directly into the e-mail body, as shown in figure 4.
@Autowired
private JavaMailSenderImpl mailSender;
public void sendMail(String from, String[] to, String[] cc, String subject, String msg) throws MessagingException {
MimeMessage message = this.mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setFrom(from);
helper.setCc(cc);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(msg, true);
mailSender.send(message);
} Figure 4: Illustration of the e-mail with the embedded extract.
2. Using the below code, the user can format it as a pdf/jpeg/png/etc. and add it as an attachment to the e-mail as shown in figure 5 (in the example, it is formatted as a pdf).
@Autowired
private JavaMailSenderImpl mailSender;
public void sendMail(String from, String[] to, String[] cc, String subject, String msg, InputStreamSource file) throws MessagingException {
MimeMessage message = this.mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setFrom(from);
helper.setCc(cc);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(msg, true);
helper.addAttachment("Credit Report", file);
mailSender.send(message);
}