12 Replies Latest reply on Nov 18, 2015 6:22 AM by Toby Erkson

    HTML code in the email body

    jegan.sivaraj

      Can we add HTML code in the Email body? I have been unable to add any HTML tags and get it to work correctly. Has anyone been successful or tried adding html to a calculated field? Google did not come up with any relevant answers.

        • 1. Re: HTML code in the email body
          Matt Coles

          Hey Jegan. Yes, you should be able to do this. I've done it with simple HTML tags in Advanced Alerts (font formatting, tables, etc). What's the calc you're using? And what does the result currently look like in the emails you're getting?

          • 2. Re: HTML code in the email body
            jegan.sivaraj

            Matt,

             

            I have a generic text with a KPI value in it. I'd like to include line breaks and possibly a table to highlight the data.

             

            This is what it looks like right now -

             

            'Center' + ' - ' + ATTR([UnitId])  + ' has exceeded the target for the week of'+' ' + ATTR([Week Name]) + ' ' + 'by' + ' ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' ' + 'hours'

            • 3. Re: HTML code in the email body
              Toby Erkson

              I'd recommend that you shorten the code.  There's too many unnecessary string concatenations.  Use this:

              'Center - ' + ATTR([UnitId]) + ' has exceeded the target for the week of ' + ATTR([Week Name]) + ' by ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' hours'
              
              

               

              Also, are you sure you need the ATTR() function?

               

              Including a break is easy, just like HTML:

              'Center - ' + ATTR([UnitId]) + ' has exceeded the target for the week of ' + ATTR([Week Name]) + '<BR>by ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' hours.'
              
              
              1 of 1 people found this helpful
              • 4. Re: HTML code in the email body
                Matt Coles

                Okay, so that looks fine. What HTML did you want in there? As an example, you should be able to do something like:

                 

                'Center' + ' - ' + ATTR([UnitId])  + ' has exceeded the target for the week of ' + ' <b>' + ATTR([Week Name]) + '</b> ' + 'by' + ' ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' ' + 'hours'

                 

                ...that would simply bold one of your values.

                 

                But it sounds like you are trying to aggregate several lines' worth of data into a single email--yes? To do that--just in case you weren't aware--you'll need to drag the " Email Consolidate ~" field into your data as well. That will append Body lines to each other for each set of unique recipients and subject.

                 

                So using that feature, you can add line breaks quite simply:

                 

                'Center' + ' - ' + ATTR([UnitId])  + ' has exceeded the target for the week of ' + ' <b>' + ATTR([Week Name]) + '</b> ' + 'by' + ' ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' ' + 'hours<br>'

                 

                If you want to do a table, you can do that too. But you will need to add in the " Email Header ~" field and " Email Footer ~" fields, which will contain the open and close tag for the table itself. Those fields are not duplicated when you consolidate the email. Instead, it goes:

                 

                Header

                Body1

                Body2

                Body3

                Body4

                Footer

                 

                So for a table, your header field should look like:

                 

                'Hey, check out my sweet table:<br><br><table>'

                 

                Body would then be:

                 

                '<tr>' +

                '<td>' +

                'Center' + ' - ' + ATTR([UnitId])  + ' has exceeded the target for the week of ' + ' <b>' + ATTR([Week Name]) + '</b> ' + 'by' + ' ' + STR(ROUND([Sheet1 (Targets)].[Target vs. Acutal],1)) + ' ' + 'hours' +

                '</td>'

                '</tr>'

                 

                Footer would be:

                 

                '</table>' + '<br><br>' + 'See! Told ya it would be sweet'

                 

                (edit: cleaned up extraneous line break tag)

                1 of 1 people found this helpful
                • 5. Re: HTML code in the email body
                  jegan.sivaraj

                  Hey Toby,

                   

                  I cannot see your code past the 'week of' +ATTR.

                   

                  I used the ATTR to get rid of the cannot combine aggregated and non - aggregated columns error.

                  • 6. Re: HTML code in the email body
                    Toby Erkson

                    You don't see a scroll bar?

                    What browser are you using?

                    • 7. Re: HTML code in the email body
                      jegan.sivaraj

                      Matt,

                       

                      I was aware of the Email Consolidation. I want to use something like your last line. Here is the result I get -

                       

                      <tr><td>Center - 00013 has exceeded the target for the week of  <b>November 1-7</b> by 2.4 hours<br></td></tr>

                      • 8. Re: HTML code in the email body
                        jegan.sivaraj

                        I cannot see a scroll bar in Chrome and Firefox.

                         

                        IE seems to work. It broke it down into several lines.

                        • 9. Re: HTML code in the email body
                          jegan.sivaraj

                          Sorry guys, I am an idiot. I was looking at the results of the viz. The email alerts have the html codes rendering correctly. Please ignore this whole discussion chain and delete if possible.

                          • 10. Re: HTML code in the email body
                            Matt Coles

                            If you joined the group, set up VizAlerts, and are already messing with advanced alerts, you're by definition "not an idiot". Glad you got it worked out!

                             

                            card-would-an-idiot-do-that.jpg

                            • 11. Re: HTML code in the email body
                              jegan.sivaraj

                              Nice quote. I learnt how to do a table in the email. So all was not lost.

                              • 12. Re: HTML code in the email body
                                Toby Erkson

                                I agree with Matt, getting this far and understanding what's going on easily gets you out of "Idiot" status   You also bring up a good point...Matt, maybe the user guide documentation needs to point this out?

                                jegan.sivaraj wrote:

                                 

                                Nice quote. I learnt how to do a table in the email. So all was not lost.

                                You're further than I am!