Skip to main content
Participant
October 30, 2024
Answered

thismailDoc with cSubject and cBody

  • October 30, 2024
  • 1 reply
  • 511 views

Hello,  I am able to get script below to generate email with Subject Line but cannot figure how to add message with fields in the body of the email. Can someone please help. Thank you.  

 

this.mailDoc({cTo: "Email@Address.com", cSubject: this.getField("PONumber").valueAsString+ " - " + "Completed QIF For JN: " + this.getField("JobNumber").valueAsString+ " at " + this.getField("Customer").valueAsString + " " + this.getField("Subdivision").valueAsString});
This topic has been closed for replies.
Correct answer S_S

Hi @ray_3008,

 

Hope you are doing well. Thanks for writing in!

 

To include a message with fields in the body of the email using your script, you can add a cMsg parameter to the mailDoc function. Here’s how you can modify your script:

this.mailDoc({
    cTo: "Email@Address.com", 
    cSubject: this.getField("PONumber").valueAsString + " - " + "Completed QIF For JN: " + this.getField("JobNumber").valueAsString + " at " + this.getField("Customer").valueAsString + " " + this.getField("Subdivision").valueAsString,
    cMsg: "Hello,\n\nPlease find the completed QIF for the following details:\n\n" +
          "PO Number: " + this.getField("PONumber").valueAsString + "\n" +
          "Job Number: " + this.getField("JobNumber").valueAsString + "\n" +
          "Customer: " + this.getField("Customer").valueAsString + "\n" +
          "Subdivision: " + this.getField("Subdivision").valueAsString + "\n\n" +
          "Thank you."
});

 

Explanation:

  • cMsg: This parameter is used to set the body of the email.
  • String Concatenation: The message is constructed using string concatenation. You can format it as needed, including line breaks (\n) for readability.
  • Field Values: The values from the form fields are incorporated into the message body.

Make sure to replace Email@Address.com with the actual recipient's email address. 

 

Hope this helps.


-Souvik

1 reply

S_S
Community Manager
S_SCommunity ManagerCorrect answer
Community Manager
October 30, 2024

Hi @ray_3008,

 

Hope you are doing well. Thanks for writing in!

 

To include a message with fields in the body of the email using your script, you can add a cMsg parameter to the mailDoc function. Here’s how you can modify your script:

this.mailDoc({
    cTo: "Email@Address.com", 
    cSubject: this.getField("PONumber").valueAsString + " - " + "Completed QIF For JN: " + this.getField("JobNumber").valueAsString + " at " + this.getField("Customer").valueAsString + " " + this.getField("Subdivision").valueAsString,
    cMsg: "Hello,\n\nPlease find the completed QIF for the following details:\n\n" +
          "PO Number: " + this.getField("PONumber").valueAsString + "\n" +
          "Job Number: " + this.getField("JobNumber").valueAsString + "\n" +
          "Customer: " + this.getField("Customer").valueAsString + "\n" +
          "Subdivision: " + this.getField("Subdivision").valueAsString + "\n\n" +
          "Thank you."
});

 

Explanation:

  • cMsg: This parameter is used to set the body of the email.
  • String Concatenation: The message is constructed using string concatenation. You can format it as needed, including line breaks (\n) for readability.
  • Field Values: The values from the form fields are incorporated into the message body.

Make sure to replace Email@Address.com with the actual recipient's email address. 

 

Hope this helps.


-Souvik

ray_3008Author
Participant
October 30, 2024

Worked! Thanks a million!!!

S_S
Community Manager
Community Manager
October 31, 2024

Thanks for letting us know that it worked for you!


-Souvik