Format message within email.OutboundAdapter

Hello,

I am looking to format my email into a few line breaks etc...is there a tutorial for this I have missed? Thanks!

Eventually, I would like to format like below:

Dear [ Name ],

Thank you for your recent visit to [ location ]. We continue to look for ways to improve and your feedback is important. Please take a few moments to complete our survey by following the link provided below, or by completing the paper survey you may have received at discharge from your recent visit at [ location ].
 
[ Click here to begin survey ]
 
At Holland Hospital, it is our goal to create an exceptional patient experience. Your feedback will help us identify opportunities for improvement that will benefit all patients.
 
If you have any questions about the survey or would like to speak to someone about your visit, please call Patient Relations at 123-456-7890.
 
Thank you for your feedback.

Sincerely,

 

 

Class HH.HAWD Extends Ens.BusinessOperation
{

Parameter ADAPTER = "EnsLib.EMail.OutboundAdapter";

Property Adapter As EnsLib.EMail.OutboundAdapter;

Parameter INVOCATION = "Queue";

Method SimpleMessage(pInput As EnsLib.HL7.Message, Output pOutput As Ens.Response) As %Status
{

    Set email=##class(%Net.MailMessage).%New()

    Set Eaddr = pInput.GetValueAt("PID:13.4")
    
    Set PtName = pInput.GetValueAt("PID:5:2")
    
    Set Lct = pInput.GetValueAt("PV1:3:1")

    Do email.To.Insert(Eaddr)

    Set email.Subject="Thank you for visiting Holland Hospital"

    Do email.TextData.Write("Thank you for your recent visit to (Lct)[ location ]. We continue to look for ways to improve and your feedback is important. Please take a few moments to complete our survey by following the link provided below, or by completing the paper survey you may have received at discharge from your recent visit at [ location ]..")

    
    Set tSc=..Adapter.SendMail(email)

    //send an empty response message after message is sent

    Set pOutput=##class(Ens.Response).%New()

    Quit $$$OK
}

XData MessageMap
{
<MapItems>

    <MapItem MessageType="EnsLib.HL7.Message">

        <Method>SimpleMessage</Method>

    </MapItem>

</MapItems>
}

}

  • 0
  • 79
  • 1
  • 1

Answers

Add:

Set email.Charset = "UTF-8"
Set email.IsHTML = $$$YES

and add text in html, for example:

Do email.TextData.Write($$$FormatText("Hello %1!<br>Thank you for visiting %2!", "Name", "Location"))

Also if your BO has only one method you can name in OnMessage and remove XData altogether.

 

If new lines is really the only thing you need formatting-wise, you can use WriteLine method and send plain text emails:

Do email.TextData.WriteLine($$$FormatText("Thank you for your recent visit to %1.", "Location"))
Do email.TextData.WriteLine("We continue to look for ways to improve and your feedback is important.")
Do email.TextData.WriteLine($$$FormatText("Please take a few moments to complete our survey by following the link provided below, or by completing the paper survey you may have received at discharge from your recent visit at %1.", "Location"))

Thanks Eduard, simple HTML answer, I appreciate it!