{"id":13813,"date":"2021-07-30T15:00:40","date_gmt":"2021-07-30T06:00:40","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=13813"},"modified":"2021-07-30T16:12:46","modified_gmt":"2021-07-30T07:12:46","slug":"google-apps-scriptgoogle%e3%83%89%e3%82%ad%e3%83%a5%e3%83%a1%e3%83%b3%e3%83%88%e6%96%87%e6%9b%b8%e3%82%92pdf%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%97%e3%81%a6%e3%83%a1%e3%83%bc%e3%83%ab%e9%80%81%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=13813","title":{"rendered":"[Google Apps Script]Google\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u6587\u66f8\u3092PDF\u306b\u5909\u63db\u3057\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b"},"content":{"rendered":"<p>\u5148\u65e5Twitter\u3067 <a href=\"https:\/\/twitter.com\/TsujiKenzo\" title=\"TSUJI KENZO\u3055\u3093 (@TsujiKenzo)\" target=\"_blank\" rel=\"noopener\">@TsujiKenzo<\/a> \u3055\u3093\u304c\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30c4\u30a4\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u9001\u4fe1\u5148\u306e\u30b7\u30b9\u30c6\u30e0\u304cShift-JIS\u3067\u30e1\u30fc\u30eb\u3092\u53d7\u3051\u53d6\u308b\u4ed5\u69d8\u3067\u3001GAS\u304b\u3089\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u3067\u304a\u56f0\u308a\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<blockquote class=\"twitter-tweet\">\n<p lang=\"ja\" dir=\"ltr\">gas\u3067gmail\u3092\u9001\u4fe1\u3059\u308b\u6642\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3063\u3066\u6307\u5b9a\u3067\u304d\u308b\u3093\u3060\u308d\u3046\u304b(\u30c7\u30d5\u30a9\u30eb\u30c8\u306fUTF-8)\u3002\u3002\u3002<\/p>\n<p>\u6700\u8fd1\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u6cbc\u304c\u6d41\u884c\u3063\u3066\u307e\u3059\u306d\u3002<a href=\"https:\/\/twitter.com\/hashtag\/GAS?src=hash&amp;ref_src=twsrc%5Etfw\">#GAS<\/a><\/p>\n<p>&mdash; TSUJI KENZO (@TsujiKenzo) <a href=\"https:\/\/twitter.com\/TsujiKenzo\/status\/1420689138991337473?ref_src=twsrc%5Etfw\">July 29, 2021<\/a><\/p><\/blockquote>\n<p> <script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script> <\/p>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b<a href=\"https:\/\/developers.google.com\/apps-script\/advanced\/gmail\" title=\"Advanced Gmail Service  |  Apps Script  |  Google Developers\" target=\"_blank\" rel=\"noopener\">Advanced Gmail Service<\/a>\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001<a href=\"https:\/\/developers.google.com\/apps-script\/reference\/mail\/mail-app\" title=\"Class MailApp  |  Apps Script  |  Google Developers\" target=\"_blank\" rel=\"noopener\">MailApp<\/a>\u30af\u30e9\u30b9\u3088\u308a\u3082\u7d30\u304b\u306a\u5236\u5fa1\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u79c1\u81ea\u8eab\u30d8\u30c3\u30c0\u30fc\u306e\u6307\u5b9a\u3084\u3089\u6587\u5b57\u5316\u3051\u3084\u3089\u3067\u82e6\u3057\u3093\u3060\u8a18\u61b6\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/Advanced Gmail Service\u4f7f\u7528\r\nfunction myFunction() {\r\n  let contents = &quot;To: (\u9001\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9)\\n&quot;;\r\n  contents += &quot;Subject: =?iso-2022-jp?B?GyRCJUYlOSVIJWEhPCVrGyhC?=\\n&quot;; \/\/\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\r\n  contents += &quot;Content-Type: text\/plain; charset=iso-2022-jp\\n&quot;;\r\n  contents += &quot;Content-Transfer-Encoding: 7bit\\n\\n&quot;;\r\n  contents += '\u001b$B$&quot;$$$&amp;$($*\u001b(B'; \/\/\u3042\u3044\u3046\u3048\u304a\r\n  \r\n  const msg = Gmail.newMessage();\r\n  msg.raw = Utilities.base64EncodeWebSafe(contents);\r\n  Gmail.Users.Messages.send(msg, &quot;me&quot;);\r\n}<\/pre>\n<p>\u305d\u3053\u3067\u4eca\u56de\u306f\u3001\u4ee3\u66ff\u6848\u3068\u3057\u3066\u6587\u5b57\u5316\u3051\u3059\u308b\u65e5\u672c\u8a9e\u306e\u672c\u6587\u3092PDF\u306b\u5909\u63db\u3057\u3001\u30e1\u30fc\u30eb\u306b\u6dfb\u4ed8\u3057\u3066\u9001\u4fe1\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function sendPDF() {\r\n  const fileName = &quot;SampleDocument&quot;;\r\n  let body = &quot;\u304a\u4e16\u8a71\u306b\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002\\n&quot;;\r\n  body += &quot;\u5f0a\u793e\u88fd\u54c1\u3007\u3007\u3078\u306e\u304a\u554f\u3044\u5408\u308f\u305b\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002\\n\\n&quot;;\r\n  body += &quot;3\u55b6\u696d\u65e5\u4ee5\u5185\u306b\u62c5\u5f53\u8005\u3088\u308a\u3054\u9023\u7d61\u3044\u305f\u3057\u307e\u3059\u306e\u3067\u3001\u4eca\u3057\u3070\u3089\u304f\u304a\u5f85\u3061\u304f\u3060\u3055\u3044\u307e\u305b\u3002&quot;;\r\n\r\n  \/\/Docs\u6587\u66f8\u3092\u4f5c\u6210\u3057\u3066PDF\u5909\u63db\r\n  const doc = DocumentApp.create(fileName);\r\n  doc.getBody().setText(body);\r\n  doc.saveAndClose();\r\n  const pdf = DriveApp.createFile(doc.getAs(&quot;application\/pdf&quot;)).setName(fileName + &quot;.pdf&quot;);\r\n\r\n  \/\/PDF\u3092\u6dfb\u4ed8\u3057\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\r\n  MailApp.sendEmail(\r\n    &quot;(\u9001\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9)&quot;, \/\/To\r\n    &quot;TEST MAIL&quot;, \/\/Subject\r\n    &quot;Please refer to the attachment.&quot;, \/\/Body\r\n    {\r\n      attachments: pdf\r\n    }\r\n  );\r\n\r\n  \/\/\u4e0d\u8981\u306b\u306a\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\r\n  DriveApp.getFileById(doc.getId()).setTrashed(true);\r\n  DriveApp.getFileById(pdf.getId()).setTrashed(true);\r\n}<\/pre>\n<p>\u4ed5\u7d44\u307f\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3001\u672c\u6587\u3092Google\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u6587\u66f8\u3068\u3057\u3066\u4e00\u6642\u7684\u306b\u4f5c\u6210\u3057\u3066PDF\u306b\u5909\u63db\u3001\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u6271\u3044\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3057\u3001\u9001\u4fe1\u5148\u306b\u3088\u3063\u3066\u306f\u53d7\u3051\u53d6\u308a\u304c\u96e3\u3057\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<span style=\"color: #ff0000; font-weight: bold;\">\u201c\u3068\u308a\u3042\u3048\u305a\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u3066\u3082\u3089\u3044\u305f\u3044\uff01\u201d<\/span>\u3068\u3044\u3063\u305f\u7528\u9014\u3067\u306f\u4f7f\u3048\u307e\u3059\u306e\u3067\u3001\u6587\u5b57\u5316\u3051\u306b\u304a\u56f0\u308a\u306e\u65b9\u306f\u8a66\u3057\u3066\u307f\u3066\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"\u5148\u65e5Twitter\u3067 @TsujiKenzo \u3055\u3093\u304c\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30c4\u30a4\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u9001\u4fe1\u5148\u306e\u30b7\u30b9\u30c6\u30e0\u304cShift-JIS\u3067\u30e1\u30fc\u30eb\u3092\u53d7\u3051\u53d6\u308b\u4ed5\u69d8\u3067\u3001GAS\u304b\u3089\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u3067\u304a\u56f0\u308a\u306e\u3088\u3046\u3067\u3059\u3002 gas\u3067gmail\u3092\u9001\u4fe1\u3059 [&hellip;]","protected":false},"author":1,"featured_media":7113,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[[Google Apps Script]Google\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u6587\u66f8\u3092PDF\u306b\u5909\u63db\u3057\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[126],"tags":[],"class_list":["post-13813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Google.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-3AN","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13813"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13813\/revisions"}],"predecessor-version":[{"id":13814,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13813\/revisions\/13814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7113"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}