gmail-mail-merge icon indicating copy to clipboard operation
gmail-mail-merge copied to clipboard

Trim Error

Open brettargh18 opened this issue 6 years ago • 9 comments

Message details TypeError: Cannot call method "trim" of undefined.

brettargh18 avatar Jul 04 '18 06:07 brettargh18

@brettargh18 @harshjv update getLatestDraft with the below and it will work

function getLatestDraft () { //var drafts = GmailApp.getDraftMessages() var drafts = GmailApp.getDrafts()[0] var message = drafts.getMessage() if (message.length === 0) return null else return message }

patrickacollier avatar Aug 10 '18 04:08 patrickacollier

Sorry it's not working,getting error: Missing ; before statement. (line 32, file "Code")Dismiss

03sarath avatar Oct 30 '18 03:10 03sarath

If you use invalid email (i.e. "email"), gmail will remove it when saving your draft. Either use valid email format (i.e. "[email protected]") as email placeholder (column header) or hardcode it in google script to resolve this issue.

//var emailPlaceHolder = draft.getTo()
var emailPlaceHolder = 'email'

krnsptr avatar Nov 10 '18 10:11 krnsptr

I've made the suggested changes to getLatestDraft but still getting the trim error.

TypeError: Cannot call method "trim" of undefined.

Any idea what the error means? I'm not a coder so it pretty meaningless to me!

DervMan avatar May 23 '19 17:05 DervMan

I got it working! I also had to make the emailPlaceHolder change. Once I did that it worked.

DervMan avatar May 23 '19 19:05 DervMan

I'm having the same issues as the guys above - @DervMan or @krnsptr or @patrickacollier would you be able to upload the full code again please?

John27208 avatar Sep 10 '19 12:09 John27208

After making the suggested changes i see an error message 'TypeError: Cannot call method "getSubject" of undefined.' ?

John27208 avatar Sep 10 '19 12:09 John27208

you can try pulling from my branch-> https://github.com/patrickacollier/gmail-mail-merge There's also a change i made to the drafts

https://github.com/patrickacollier/gmail-mail-merge/commit/8e144c2e6a6429faa35cb58445ebb763ec2572f0#diff-a5d3061c9dfd2cc892c25d05230d7cc2

On Tue, Sep 10, 2019 at 8:28 AM John27208 [email protected] wrote:

After making the suggested changes i see an error message 'TypeError: Cannot call method "getSubject" of undefined.' ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/harshjv/gmail-mail-merge/issues/2?email_source=notifications&email_token=ADLJ3XMNRYNFBTPWFXJ2R53QI6HITA5CNFSM4FIIBQ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6K47VA#issuecomment-529911764, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLJ3XPQUVU5OTIOEMJTVYTQI6HITANCNFSM4FIIBQ6Q .

patrickacollier avatar Mar 12 '20 18:03 patrickacollier