Skip to Content

Communication in any industry has its own significance and email is a very powerful mode of communication where high tech industry is involved. xMII provides us with the facility of sending email whenever a crucial thing is involved. It has a basic email action block which can be used to send emails for important emails. In this blog I’m going to focus on two things:

  • Configuring      the basic ‘send email’ action block.
  • Using      a trick to send the information in HTML format.

 The prerequisite for the readers of this blog is to have basic knowledge of xMII action blocks and templates.

Configuring the send email action block

Configuring the send email action block is quite easy of a thing.

 

 

All he fields can be set dynamically(and ideally they should be used that way using link editor). But for the sake of simplicity, I’m hardcoding these values in this example.

 

Please note here that I’ve set message content type as text/html because we are going to use a html template.

 

Configuring The Data to be displayed

Now we are going to send the status of all the three fans(the default simulator) using email action block of BLS in HTML format.

Write a tag query using simulator with fan1, fan2 and fan3 as output and save it as ‘Demo/Fanstatus’.

 

     

 

Designing the HTML template

 

Now this trick has helped me a lot. Design a HTML template as shown in the picture. Save it as “d:\demotemp.html”.

 

 

 

Here, you may see that I’ve given following keywords:

  • date_it – this will be used for displaying the current date and time in the email.

Following keywords will be used for showing the fan state of the respective fans.

  • fn1_st
  • fn2_st
  • fn3_st

 

Creating The Business Logic 

Since we are done with the things requirement gathering ;). So, we have to develop a transaction which will be used for sending the email in HTML format.

 

  • Go to      logic editor and insert a tagquery action block. Call the ‘Demo/Fanstatus’      query in it.

 

  • Add a      the html loader action block and the load the template(d:\demotemp.html).

 

  • Create      a new local string variable and name it ‘message’.

 

  • Add an      assignment action block and assign the string content value of html loader      action to local variable message.

 

 

  • Now      add one more assignment action block and add the following code to      local variable ‘message’.

 

stringreplace(stringreplace(stringreplace(stringreplace(Local.message  , “fn3_st”, stringif( IllumTagQuery_0.Results{/Rowsets/Rowset/Row/Fan3}==1, “ON”, “OFF” ) )  , “fn2_st”, stringif( IllumTagQuery_0.Results{/Rowsets/Rowset/Row/Fan2}==1, “ON”, “OFF” ) )  , “fn1_st”, stringif( IllumTagQuery_0.Results{/Rowsets/Rowset/Row/Fan1}==1, “ON”, “OFF” ) )  , “date_it”, IllumTagQuery_0.Results{/Rowsets/Rowset/Row/DateTime} )

 

 

This code will modify the html template accordingly. It consists of two things:

stringreplace(Local.message  , “fn3_st”, stringif( IllumTagQuery_0.Results{/Rowsets/Rowset/Row/Fan3}==1, “ON”, “OFF” ) ) 

this code will first search for the keyword called “fn_3st” in the HTML string and then it will replace it with ON or OFF depending on the value we get from fan3 status from the tag query.

 

  • Now      comes the final part. Configure an email action block as specified earlier      and assign the message variable to the message part of the ‘sendmail’ action      block.

 

And now run the transaction. The output email will be something like this.

 Final Output

 

This trick can be used to send detailed informations to the concerned person and can be used to handle more complex scenarios of table generation on the fly using XSLT.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply