Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Mail Merge in Gmail doesn't work #155

Open
audioa86 opened this issue Sep 17, 2020 · 19 comments
Open

Mail Merge in Gmail doesn't work #155

audioa86 opened this issue Sep 17, 2020 · 19 comments
Labels
bug Something isn't working

Comments

@audioa86
Copy link

The first 2 times I tried Mail Merge in Gmail by following the directions here it worked. However, beginning yesterday, it has stopped working. The markers in the email draft correspond to the column headers in the Google Sheet. (I copied the header names and pasted them in the email draft with the double brackets around them, like this: {{First name}}. The emails will send with the email draft to the recipients listed in the Google Sheet, but none of the fields within the email body will fill in. Instead there are blanks where they are missing. This seems like a glitch in the system. What can I do to fix this?

@audioa86 audioa86 added the enhancement (new solution) Suggest a new solution for the gallery label Sep 17, 2020
@sqrrrl sqrrrl added bug Something isn't working and removed enhancement (new solution) Suggest a new solution for the gallery labels Sep 22, 2020
@drlube
Copy link

drlube commented Sep 23, 2020

I tried the sheet/script for the first time today, and am experiencing the same issue.

@fizzatbeyond
Copy link

My wife encountered the same problem. She had previously used to generate approximately 500 emails without an issue however this time when generating about 1200 emails the data was blank. She broke it into two smaller groupings and they both went through with all the data as expected.

I suspect the problem has to do with some maximum number of rows or amount of data being processed.

@audioa86
Copy link
Author

Unfortunately, it doesn't have to do with maximum rows of data for me. I was demonstrating how to use the tool by using only 2 rows of test data (with real email addresses) when this stopped working properly.

@vanowarna
Copy link

The same occurred to me with just 2 rows. Emails were sent separately and the {{ }} in the subject was Changed as expected. But the body was blank. Is there a fix?

// loop through all the rows of data obj.forEach(function(row, rowIdx){ // only send emails is email_sent cell is blank and not hidden by filter

Line 81 : What is rowIdx that hasn't mentioned anywhere. I suspect that's the issue. Any fixes?

@CampbellDuke
Copy link

I'm having the same issue - using just one line as a test.

@vanowarna
Copy link

vanowarna commented Jan 21, 2021

Found a solution.

It worked for me. When pasting the names of the columns in the email body. Paste them as plain text(ctrl+shift+v). Otherwise the formatting interrupts the algorithm.

There's no issue with the code. It's just the email body

@CampbellDuke
Copy link

Thanks vanowarna. I just tried clearing all formatting and sending a test to myself again. Same issue. Then I just typed in my name and email address after clearing formatting in all cells. Ditto.

I still think it's useful, it just looks like I won't be able to personalize things.

@gsaxer
Copy link

gsaxer commented Jan 23, 2021

I have this same issue today.
The part which is very confusing is that if I look at the email using "Show Original" I CAN SEE THE INSERTED TEXT just fine. The HTML version as well as the info at the bottom does NOT have the text though.

For example, the draft email has

{{Discount code}} 4
{{First name}} 5

in it.

In the non-HTML part of the Show Original I see

xx 4
Gary 5

(Those are the right test values in the spreadsheet.)

However, in the area with

Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I can see

4
5

So somehow the actual text is getting dropped.

@vanowarna
Copy link

I have this same issue today.
The part which is very confusing is that if I look at the email using "Show Original" I CAN SEE THE INSERTED TEXT just fine. The HTML version as well as the info at the bottom does NOT have the text though.

For example, the draft email has

{{Discount code}} 4
{{First name}} 5

in it.

In the non-HTML part of the Show Original I see

xx 4
Gary 5

(Those are the right test values in the spreadsheet.)

However, in the area with

Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I can see

4
5
So somehow the actual text is getting dropped.

Did you try this #155 (comment)

@gsaxer
Copy link

gsaxer commented Jan 23, 2021

Yes, indeed I made sure that there was no formatting of the names in {{}}.
Note in my example there's a 4 and 5. That's because I had multiple tests. One was an exact copy from the spreadsheet into the draft email and that included the name being in bold and another was it as plain text.

I also see that the quoted-printable stuff is getting "processed" by Github's comment section. Ugh. Let me see if I can post it again:

"

<spa=
n style=3D"color:rgb(0,0,0);font-family:Roboto,RobotoDraft,Helvetica,Arial,=
sans-serif;font-size:13px;white-space:pre-wrap"> 4
<span s=
tyle=3D"color:rgb(0,0,0);font-family:Roboto,RobotoDraft,Helvetica,Arial,san=
s-serif;font-size:13px;white-space:pre-wrap"> 5
"

(In the preview this info is now showing. This is the relevant chunk of stuff in the email from which the displayed email is generated. It's at the end of Show Original.)

This HTML stuff shows the 4 and 5 but not the values from the spreadsheet. As mentioned before, in the text of the Show Original the values from the spreadsheet are THERE. Something is happening when the "conversion" to HTML is taking place.

@gsaxer
Copy link

gsaxer commented Jan 23, 2021

Update - The account I'm using to do this Mail Merge is a "G Suite" version.
I just tried this same thing in my personal email account and the values from the spreadsheet now appear in the sent emails!

Significantly, in the quoted-printable section of Show Original there's none of the style or other stuff, it's just

"

z 4
Gary 5

image
"

which are the values from the spreadsheet and the number next to the value.
(The above is the actual code in the quotes and then an image snipped from the screen because I can't get this editor to drop processing it as HTML.)

@gsaxer
Copy link

gsaxer commented Jan 24, 2021

Another update:
Based on this "plain text" concept I decided to select the entire draft email and then "cut" it so the email body was empty. Then did a ctrl-shift-v (paste as plain text) for the draft email. A little "cleaning up" was needed - mostly putting in come extra "return" items at the places where an empty line was desired after a paragraph.

THIS WORKED - even in the GSuite version.

So, getting rid of all "formatting" in the email did the trick. I note that the sent email automatically had any web "links" converted to a clickable link (which is fine) but otherwise all the other formatting was "plain" in the resulting email. However, the values from the spreadsheet were put in the right place where {{Discount code}} etc. were.

Success!

@brew-guy
Copy link

brew-guy commented Jan 26, 2021

I had the same problem and found that it worked when I removed all formatting from the mail draft/template (including the mail signature).
Another strange behaviour was that if the case of my {{}} tags were lowercase, the script would not return a "String contains control character" but instead complete the merge with the problematic field empty in the generated mail.
If case of tags and merge sheet headers were equal, it would return the control char error.

@rupayvidya
Copy link

Thank You @gsaxer
You made my Day.
I followed your steps by copying the complete mail and pasting it as plain text. It worked.

Thank you very much.

@timhughes-dev
Copy link

My colleague is having the same problem with fields appearing blank in the emails sent.

The script is working fine for me. I've tried adding formatting and it still works fine. Does anyone have any other suggestions on what else my colleague should try to solve this?

@yotiko
Copy link

yotiko commented Aug 23, 2022

thnx folks for the solution, has somebody found a solution for the formating problem?
i would like to make some text to appear bold

@jyotingautam
Copy link

jyotingautam commented Jun 9, 2023

@yotiko The summary of the solution is:

  1. convert your email body to plain-text as @gsaxer explains. i.e.
    (a) First cut your entire email body with cntrl-X (or cmd-x on Macbook) and then
    (b) Then pasting unformatted using cntrl-shift-v (or cmd-shift-v on Macbook)
    3.For formatting the email, next step is to select the text to format (but don't touch the Mail-merge variables!!) and format the the text using bold, italic etc. Don't touch the mail-merge variables when re-formatting!

This worked fine for me. @gsaxer was a lifesaver - thanks!

@MsTsam000
Copy link

@gsaxer you are life saver...spent almost 4 hrs trying to find the solution by scouring youtube. So I am confirming that changing the text formatting by converting the body of the email to " Plain Text" via the (Crt+Shift+V) was the solution.
I was never a member of this forum...but found it via google and I had to sign up to show my gratitude!

So Thanks again @gsaxer !

@Fidle123
Copy link

The same occurred to me with just 2 rows. Emails were sent separately and the {{ }} in the subject was Changed as expected. But the body was blank. Is there a fix?

// loop through all the rows of data obj.forEach(function(row, rowIdx){ // only send emails is email_sent cell is blank and not hidden by filter

Line 81 : What is rowIdx that hasn't mentioned anywhere. I suspect that's the issue. Any fixes?

Thanks, Vanowarna

Great help.

It worked for me too, with this method as well. By removing the formatting and typing inside the curly brackets exactly as it is example {{First name}}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests