[技術討論] 想用 Google Docs 作為 Email template 咁 send email, 應該點做?

我有一份 Google Doc 文件作為示範, 想用 Google Script api 去 get 到個 Document header 做 title, body 做 email content 去 放落我個 email 度之後 send 出去, 我可以點做?



我有一個 Google Sheet 用來控制 send email, 目標想係上面打上收件人, CC, BCC, 再寫返 Document ID 同 title, 之後就會自己搵返上面我份 document 放落我自己個 email 度
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

回覆 1# jacky_chua



呢個係我暫時寫既 code
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

本帖最後由 javacomhk 於 2022-4-25 04:31 編輯

Check the Docs reference to locate the document
https://developers.google.com/apps-script/reference/document

and the GmailApp method is used to send email
https://developers.google.com/ap ... nce/gmail/gmail-app

TOP

我有睇過下, 不過我想將個 Docs 轉成我 email body 可以點做?

TOP

本帖最後由 javacomhk 於 2022-4-25 11:27 編輯
我有睇過下, 不過我想將個 Docs 轉成我 email body 可以點做?
jacky_chua 發表於 2022-4-25 04:45


其實就好似Spreadsheet咁整個 table 出來,跟住 app script 攞個 Table Data 來用。最後個 doc 嘅  table 就將個 table property 的 border 變 0 pt 。tables[0].setBorderWidth(0);

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

或者用 getParagraphs() 如果唔係 table 的話。

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

Okay, 係唔係最好都係Google Docs 用一個大表格裝哂我既資料, 之後就逐個 cell 咁樣 call 返 data 出來會好D?
因為我個 SendEmail Google sheet 係 共用 (姐係諗住只要打個 document ID, 個 script 就會去對應既 Google Docs 自己生成 HTML body 再放落我個 email body 度), 咁我係唔係要去 Google Docs 寫個 script 自己將個 Google Docs content 砌做一個 html ?

TOP

本帖最後由 javacomhk 於 2022-4-26 03:03 編輯
Okay, 係唔係最好都係Google Docs 用一個大表格裝哂我既資料, 之後就逐個 cell 咁樣 call 返 data 出來會好 ...
jacky_chua 發表於 2022-4-25 17:07

咁即係mail merge 功能啫。你google 搵吓,好多sample。

https://developers.google.com/ap ... omations/mail-merge

TOP

咁即係mail merge 功能啫。你google 搵吓,好多sample。
javacomhk 發表於 2022-4-26 10:20


佢呢個係用我 Gmail draft 做 template, 不過我係想用 Google Docs, 可唔可行?

TOP

Google Docs 係文書用,冇預你用嚟做 email 排版,格式複雜少少對方收到隨時會走樣,尤其是 Gmail 及 Outlook

建議放棄 Google Docs,用 MJML

TOP