Rich Text Mail Merge using Apps Script - google-apps-script

I tried two options for mail merge but I am not able to retain the formatting.
I don't want to save the email content in the HTML file of the code because I want it to be easy to update the email template for someone who does not know coding.
Using the regular mail merge code from google apps script where email content is stored in a cell of the sheet. But I want this content to be formatted - bullets, urls, bold etc.
Reference: https://developers.google.com/apps-script/articles/mail_merge
(Most effective so far) Using advanced version of regular mail merge but the variables cannot be formatted.
Refernce: https://developers.google.com/gsuite/solutions/mail-merge
Using a google doc template which has variables that will be filled from spreadsheet using a script. Then this content needs to be emailed without the formatting being lost. I am able to set the variables and send personalized emails, but the formatting (bold, bulleted list, new lines, urls) is being lost. How do I retain the formatting?
Reference : https://katydecorah.com/code/google-sheets-to-gmail-template/
Sample Doc Template
Hello {Name},
Here is your confirmation number {Number}.
Please bring the following items.
List item
List item
Please visit this website www.google.com for more details

Related

Google Forms / Excel / Gmail Integration - Linking the Excel Sheet to the Google Docs template which will be used in the e-mail

I am a legal ops specialist working in a law firm with an interest of coding but have no practice lately. (I had python course during my studies but that was years ago)
Therefore I may be asking a very easy question, because I used an existing template and modified it for our process, however because of my lack of information on the topic I can't find the cause of the problem we are having.
So this is the template I used and the guide about it.
The problem is, when i filled the form any send a mail to the approvals it doesn't fill the answer template(docs) so the e-mail I receive comes as following;
table in the email template which is supposed to be fed from the google sheet
Which is basically the names of the google sheets columns, not the value in the cell. I believe the problem might be about the following piece of code;
// We start with the doc template HTML body, and then we replace
// each '{{fieldName}}' with the row's respective value.
let emailBody = headers.reduce(
(result, fieldName) => result.replace(`{{${fieldName}}}`, row[fieldName]),
docToHtml(templates.get(emailTemplate || action))
);
OR, because I couldn't manage to link the table in the google docs template with the answer sheet and I don't know how to do it.
Any kind of help is appreciated, I'm very cold and lost out here.
Edit1: Screenshots of the answer sheet and related part of the code.
answer sheet - columnsconst part of the code
Edit2: I added a screenshot of the template provided by Google. You can see that there is a link between the template and the answer sheet. I couldn't manage to restore such link when I changed the google docs template. Google docs template
After a lot of testing, as strange as it sounds, i have discovered that the main issue is the font type.
Also, it appears not possible to use a placeholder more than 1 time on the same email.
The evidence i have is that, by using a text editor to create the placeholder, i set ALL of the values in the doc row to {{Name}}, and in the Form Responses i set the name value to 1000.
The first 1 worked, then i typed over the second value with a different placeholder, and it began to work too.
So, you should recreate all the placeholders in a text editor, then copy and paste them onto the doc.

Mailto Hyperlink Limitations?

I am attempting to create a VBA Macro that will automatically send emails based on attributes within my spreadsheet - within each email is HTML code with <a href ="mailto:...> hyperlinks. The cc and bcc fields in those hyperlinks are dynamic as well.
I create the HTML code for the hyperlinks within the excel spreadsheet itself by using Concatenate to create the following values:
send email
In order to test that it works, I display the olmailitem before sending. All of my hyperlinks work perfectly when the olmailitem is displayed. However, when I send the email to myself to test it from my Outlook, one of the hyperlinks fails to open. There is no error message - it just does not open.
The one difference between the mailto hyperlink that does not work and the others is that there are around 70 emails that are BCC'ed in the html. The length of this mailto hyperlink is 1683 characters.
I think that my issue is that there is a maximum length to a URL that outlook can handle from its desktop application. However, I don't know what that length is. Does anyone have insight?

How do I create a google form template using google script?

I have created a google form which I would like to convert to a template. The objective is to to distribute this template to other people so they can amend the form as they see fit. I also need these amended forms to sit inside a directory in the google drive.
How can I construct a google script to convert the original form into a template?
Thus far I have
var form = FormApp.openById('asdfasdfasdfasdfasdfasdfFORMIDGOESHEREfasdfasdfa');
I am stuck on how to take this form and now convert it to a template.
If you want to get the whole form and then transform it into a template to modify it at will, it is not feasible. But instead, if you want to get certain elements and modify them or create a new form using Apps Script you can check the Class Form, which gives you several methods that will allow you to insert or removes elements.

UiPath integration with Linkedin - Html characters not preserving formatting

We have an RPA on a site, to post a form. In the form we want to send HTML content with formatting. But the site is removing all the formatting, and is just showing html characters as is (like a text). But when we are copy pasting the content from tinymce editor (at our end) to the same site's form it is showing the content properly with formatting.
What needs to be done from my end while sending data to UiPath so that it puts the content in proper html format with formatting preserved?
I also tried sending html codes encoded by gson which is done by default. That also did not work.
This is when we are copy pasting the content -
And this is when we are sending data via uipath -
EDIT
This is what the uipath activity looks like (The description is being sent by an http api which uipath calls to get data) -
Thanks
Better use the Assign activity:
In the String variable website you simply save the HTML page. Now you can easily paste the variable anywhere. Also you don't need to paste the HTML in your editor via CTRL+V.
Just use the Type into activity:

Insert the entire contents of one Google Doc into the comment of another

The problem
I'm interested to know if it is possible to copy the entire contents of one Google Doc and paste into a comment in another Google Docs using keyboard commands.
Background-
I do a lot of grading of student papers and have a range of standard comments I use which are individually stored in separate documents. I use Macros and keyboard shortcuts in MS Word to grab the contents of the comment file I want and put it into a comment in the paper I'm grading. I edit the macro files using the VB editor when necessary. It works quite efficiently.
I found some related material in my research, however this don't quite match what I am trying to do.
I think the code from here Insert comment into Google doc does something like what I want, but kind of the opposite.
Google Apps Scripts is new to me. I'm not really looking to become a programmer, I just need to know if developing such a script is possible or not and how hard it would be. I would appreciate being pointed in the right direction. Thanks.
A sample to point you into the right direction:
function myFuction()
{
var fileOriginId='PASTE HERE THE ID OF THE FILE WITH THE COMMENT TEXT';
var fileDestinationId ='PASTE HERE THE ID OF THE FILE WHERE THE COMMENTS SHALL BE INSERTED';
var text=DocumentApp.openById(fileOriginId).getBody().getText()
var comment={ 'content': text};
Drive.Comments.insert(comment, fileDestinationId);
}
This code snippet passes the whole contents of a Google Docs document to the variable text. Subsequently, the contents of text is inserted as a comment into a second Google Docs document. It uses the Advanced Drive Service that needs to be enabled beforehand.
Should you desire to pass only a part of the text in the original file into the comment, e.g. a paragraph, you would need to chose the specific paragraph instead of the whole document body.
Should you desire to append the comment to a certain text within the destination document, you need to use the optional property context.value, as done in the reference you provided.
Please find here references to useful documentation that will help you
udderstand Apps Script and adjust the code snippet provided to your
requirements:
DocumentApp to access Google Docs documents
Body of a document
Retrieve children of a document
Advanced Drive Service
Enable Advanced Services
Insert comments with Advanced Drive Service