John Mark
John Mark

Reputation: 119

email body getting error: TypeError: Cannot read property

The string from my gmail body message seems not to be working. I'm getting this error:

But when I'm using a static variable for html. I don't have any errors at all (I'm receiving the last success message 'SUCCESS but not found.. so this is still OK...' and that's what I wanted but I dont want to use the static variable).

This is the full source code in google app script

Please see [this video for my demo.][2]

  [1]: https://pastebin.com/acBHN63S
  [2]: https://www.useloom.com/share/08525a017c574698a88f951cf04d7815

Error: Screenshot of the error Execution transcript from the editor:

[18-01-27 13:24:35:056 HKT] Starting execution
[18-01-27 13:24:35:079 HKT] SpreadsheetApp.getUi() [0.015 seconds]
[18-01-27 13:24:35:299 HKT] GmailApp.search([from:[email protected] in:inbox, 0, 1]) [0.218 seconds]
[18-01-27 13:24:35:478 HKT] GmailThread.getMessages() [0.178 seconds]
[18-01-27 13:24:35:479 HKT] GmailMessage.getDate() [0 seconds]
[18-01-27 13:24:35:799 HKT] GmailMessage.getBody() [0.32 seconds]
[18-01-27 13:24:40:027 HKT] Ui.alert([Success! URL FOUND!: 
https://www.linnake.fi/e1t/c/*W7jytSj66jddKW1p_c9t3s4gsp0/*W3BkDbD4Xs7kfW4tJh-k19HByV0/5/f18dQhb0Sjv98XJ9RdW8C8HT52qwv1SV6bgdG2shkfGMf5pP-XD6prW7cmS1s8pCQ6vW25G0-N51_rSsW3Tmswx61]...) [4.227 seconds]
[18-01-27 13:24:40:108 HKT] UrlFetchApp.fetch([https://www.linnake.fi/e1t/c/*W7jytSj66jddKW1p_c9t3s4gsp0/*W3BkDbD4Xs7kfW4tJh-k19HByV0/5/f18dQhb0Sjv98XJ9RdW8C8HT52qwv1SV6bgdG2shkfGMf5pP-XD6prW7cmS1s8pCQ6vW25G0-N51_rSsW3Tmswx61SSZmW7mG7sD51vX4yW6HBR, {=}]...) [0.079 seconds]
[18-01-27 13:24:40:235 HKT] Execution failed: TypeError: Cannot read property "1" from null. (line 51, file "Code") [5.152 seconds total runtime]

Upvotes: 1

Views: 387

Answers (1)

John Mark
John Mark

Reputation: 119

Found the answer guys. replaced the regex /g flag to /i

from this source: Interesting test of Javascript RegExp

Upvotes: 1

Related Questions