Not getting 100% of my email body being composed

body = [[\<html\> &nbsp; &nbsp;\<body\> &nbsp; &nbsp; &nbsp; &nbsp;\<p\>Incident Date:]] .. myData.dateDay .. " / " .. myData.dateMonth .. " / " .. myData.dateYear .. [[\</p\> &nbsp; &nbsp; &nbsp; &nbsp;\<p\>Line 2 \</p\> &nbsp; &nbsp;\</body\> \</html\>]] }

I don’t know how useful this will be, but [[starts a multi-line string and]] closes it.  In you case, Line 2 is just fixed text. You’re not using a variable for it, so the last place where data is inserted you close that line with [[</p>  after that put your next HTML tags on the next line.  But you probably want more than “Line 2” to print, you want to do more variables, so something like this will be a better example:

body = [[\<html\> &nbsp; &nbsp;\<body\> &nbsp; &nbsp; &nbsp; &nbsp;\<p\>Incident Date:]] .. myData.dateDay .. " / " .. myData.dateMonth .. " / " .. myData.dateYear .. [[\</p\> &nbsp; &nbsp; &nbsp; &nbsp;\<p\>Incident Description:]] .. myData.description .. [[\</p\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<p\>Name:]] .. myData.name .. [[\</p\> &nbsp; &nbsp;\</body\> \</html\>]] }

OF course I’m making things up there, but hopefully it will provide better syntax for you to work with.

Rob

Thanks for that extension here Rob this has really helped.

Thanks again,

Matt.

It seems as if it is in fact working now but the only issue is that it is making three empty lines between each paragraph is there a way to make it only create one empty line between each line rather than three?

Matt.

What device are you testing on?  Different email clients might have different spacings for paragraphs.  3 lines seems weird though, usually it’s one empty line between.  Any way, you can attack it with HTML by starting the whole message with a <p> and close the whole thing with another </p> and then use <br /> tags to put each line of the paragraph on a newline and avoid whatever default spacing your mail client’s app is applying to the paragraph tags.

The other option is to insert a little CSS to change how the <p> tag behaves.  Something like this:

\<html\> &nbsp;&nbsp;&nbsp; \<head\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \<style\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p { margin-bottom: 5px; padding-bottom: 0px; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \</style\> &nbsp;&nbsp;&nbsp; \</head\> &nbsp;&nbsp;&nbsp; \<body\> &nbsp;&nbsp;&nbsp; ....

Rob

Hi Rob,

I tried adding the css style to my function and it just made it appear as normal text in the email. Am I doing this correctly?

[lua]

local function OnbtnSend( event )

– compose an HTML email with two attachments

local options =

{

  to = { “MobileDevelopmentTesting@gmail.com” },

  subject = “Incident Report”,

  isBodyHtml = true,

body = [[<html>

<head>

        <style>

              p { margin-bottom: 5px; padding-bottom: 0px; }

          </style>

          </head>

         

  <body>

       <p>Incident Date: ]] … myData.dateDay … " / " … myData.dateMonth … " / " … myData.dateYear … [[</p>

       <p>Incident Time: ]] … myData.timeHour … " : " … myData.timeMinute … [[</p>

       <p>Did the Incident Cause Harm?: ]] … myData.IRb1 … [[</p>

       <p>Who Was Affected By or At Risk By the Incident?: ]] … myData.IRb2 … [[</p>

       <p>Where Did the Incident Take Place?: ]] … myData.incidentLocation … [[</p>

       <p>Severity of Harm or Damage Caused: ]] … myData.IRb3 … [[</p>

       <p>Indicated Part of the Body Affected: ]] … myData.injuryOccurred … [[</p>

       <p>What Caused the Incident?: ]] … myData.IRb4 … [[</p>

       <p>If Caused By Height, Distance Of Fall?: ]] … myData.fallHeight … [[</p>

       <p>If Other, Description of Selection?: ]] … myData.textOther … [[</p>

       <p>Brief Description: ]] … myData.breifDes … [[</p>

       <p>Medical Intervention: ]] … myData.IRb5 … [[</p>

       <p>What Was the Outcome?: ]] … myData.IRb6 … [[</p>

       <p>Immediate Action Taken: ]] … myData.actionTaken … [[</p>

       <p>Person(s) Affected By the Incident (Name): ]] … myData.nameAffected … [[</p>

       <p>Person(s) Affected By the Incident (Email): ]] … myData.affectedEmail … [[</p>

       <p>Person(s) Affected By the Incident (Phone): ]] … myData.affectedPhone … [[</p>

       <p>Person(s) Affected By the Incident (Student Info): ]] … myData.studentSchool … [[</p>

       <p>Person(s) Affected By the Incident (Staff Info): ]] … myData.staffDepartment … [[</p>

       <p>Person(s) Affected By the Incident (Staff Line Mgr): ]] … myData.lineManagersName … [[</p>

       <p>Witnesses to the Incident:(Name): ]] … myData.witnessName … [[</p>

       <p>Witnesses to the Incident:(Email): ]] … myData.witnessEmail … [[</p>

       <p>Witnesses to the Incident:(Phone): ]] … myData.witnessPhone … [[</p>

       <p>Witnesses to the Incident:(Student Info): ]] … myData.witnessStudentSchool … [[</p>

       <p>Witnesses to the Incident:(Staff Info): ]] … myData.witnessStaffDepartment … [[</p>

       <p>Person Reporting the Incident:(Name): ]] … myData.reportingName … [[</p>

       <p>Person Reporting the Incident:(Email): ]] … myData.reportingEmail … [[</p>

       <p>Person Reporting the Incident:(Phone): ]] … myData.reportingPhone … [[</p>

       <p>Person Reporting the Incident:(Student Info): ]] … myData.reportingStudentSchool … [[</p>

       <p>Person Reporting the Incident:(Staff Info): ]] … myData.reportingStaffDepartment … [[</p>

   </body>

</html>]] }

local result = native.showPopup(“mail”, options)

if not result then

print( “Mail Not supported/setup on this device” )

native.showAlert( “Warning!”,

“ERROR: Mail not supported/setup on this device. Contact Support”, { “OK” }

);

end

– NOTE: options table (and all child properties) are optional

end

[/lua]

Thanks again,

Matt.