{"id":10760,"date":"2018-08-29T15:00:43","date_gmt":"2018-08-29T06:00:43","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=10760"},"modified":"2019-05-21T14:50:00","modified_gmt":"2019-05-21T05:50:00","slug":"google-apps-script%e3%83%a1%e3%83%bc%e3%83%ab%e3%81%8b%e3%82%89message-id%e3%83%98%e3%83%83%e3%83%80%e3%83%bc%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=10760","title":{"rendered":"[Google Apps Script]\u30e1\u30fc\u30eb\u304b\u3089Message-ID\u30d8\u30c3\u30c0\u30fc\u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/excelspeedup\" title=\"\u306f\u3051\u305f\uff20Excel\u6700\u9ad8\u306e\u5b66\u3073\u65b9\u767a\u58f2\u4e2d(@excelspeedup)\u3055\u3093\" target=\"_blank\" rel=\"noopener noreferrer\">\u306f\u3051\u305f(@excelspeedup)<\/a>\u6c0f\u306e\u30c4\u30a4\u30fc\u30c8\u3067\u3001GAS\u3067\u30e1\u30fc\u30eb\u306eMessage-ID\u30d8\u30c3\u30c0\u30fc\u304c\u53d6\u5f97\u3067\u304d\u308b\u306e\u304b\uff1f\u3068\u3044\u3063\u305f\u5185\u5bb9\u306e\u3082\u306e\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"ja\">\n<p lang=\"ja\" dir=\"ltr\">GAS\u3067\u30e1\u30fc\u30eb\u53d7\u4fe1\u306b\u9023\u52d5\u3057\u3066\u51e6\u7406\u3092\u3059\u308b\u4ed5\u7d44\u307f\u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u304d\u306b\u3001GAS\u3067\u300cMessage-Id\u300d\u3082\u53d6\u5f97\u3067\u304d\u308b\u306e\u304b\u306a\uff1f<br \/>\u91cd\u8907\u51e6\u7406\u3092\u9632\u3050\u306b\u306f\u305d\u306e\u6b04\u3092\u898b\u308b\u306e\u304c\u4e00\u756a\u7121\u96e3\u306a\u6c17\u304c\u3059\u308b<\/p>\n<p>&mdash; \u306f\u3051\u305f\uff20Excel\u6700\u9ad8\u306e\u5b66\u3073\u65b9\u767a\u58f2\u4e2d (@excelspeedup) <a href=\"https:\/\/twitter.com\/excelspeedup\/status\/1033991868088893441?ref_src=twsrc%5Etfw\">2018\u5e748\u670827\u65e5<\/a><\/p><\/blockquote>\n<p><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>\u305f\u3057\u304b\u30e1\u30fc\u30eb\u30d8\u30c3\u30c0\u30fc\u3082\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u305f\u306f\u305a\u306a\u306e\u3067\u3001\u3055\u3063\u305d\u304f\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/\u30e1\u30fc\u30eb\u304b\u3089Message-ID\u30d8\u30c3\u30c0\u30fc\u3092\u53d6\u5f97\r\nfunction getMessageIdHeader() {\r\n  var msg = GmailApp.getInboxThreads(0, 1)&#x5B;0].getMessages()&#x5B;0];\r\n  var content = msg.getRawContent();\r\n  var matches = content.match(\/^Message-ID:.*$\/gim);\r\n  if (matches !== null) {\r\n    for (var i = 0; i &lt; matches.length; i++) {\r\n      Logger.log(matches&#x5B;i]);\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u30b3\u30fc\u30c9\u306f\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u3067\u3001<a href=\"https:\/\/developers.google.com\/apps-script\/reference\/gmail\/gmail-message#getRawContent()\" title=\"Class GmailMessage  |  Apps Script  |  Google Developers\" target=\"_blank\" rel=\"noopener noreferrer\">GmailMessage.getRawContent<\/a>\u30e1\u30bd\u30c3\u30c9\u3067\u30e1\u30fc\u30eb\u306e\u30bd\u30fc\u30b9\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u53d6\u5f97\u3057\u3001match\u30e1\u30bd\u30c3\u30c9\u3067\u300cMessage-ID\u300d\u3092\u629c\u304d\u51fa\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<br \/>\n(\u4e00\u3064\u306e\u30e1\u30fc\u30eb\u306bMessage-ID\u30d8\u30c3\u30c0\u30fc\u304c\u8907\u6570\u3042\u308b\u3053\u3068\u306f\u7121\u3044\u306e\u3067\u3001\u30eb\u30fc\u30d7\u3055\u305b\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u78ba\u8a8d\u306e\u305f\u3081\u306b\u30eb\u30fc\u30d7\u3067\u56de\u3057\u3066\u3044\u307e\u3059\u3002)<\/p>\n<p>\u307e\u305f\u9006\u306b\u3001\u300c<a href=\"https:\/\/support.google.com\/mail\/answer\/7190?hl=ja\" title=\"Gmail \u3067\u4f7f\u7528\u3067\u304d\u308b\u691c\u7d22\u6f14\u7b97\u5b50 - Gmail \u30d8\u30eb\u30d7\" target=\"_blank\" rel=\"noopener noreferrer\">rfc822msgid:<\/a>\u300d\u691c\u7d22\u6f14\u7b97\u5b50\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001Message-ID\u30d8\u30c3\u30c0\u30fc\u304b\u3089\u30e1\u30fc\u30eb\u3092\u691c\u7d22\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u306e\u3067\u3001\u305d\u306e\u305f\u3081\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3082\u3064\u3044\u3067\u306b\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function sample() {\r\n  var msg = getMessageFromMessageID(&quot;Message-ID\u30d8\u30c3\u30c0\u30fc&quot;);\r\n  if (typeof msg !== &quot;undefined&quot;) {\r\n    Logger.log(msg.getSubject());\r\n  }\r\n}\r\n\r\n\/\/Message-ID\u30d8\u30c3\u30c0\u30fc\u3092\u6307\u5b9a\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u53d6\u5f97\r\nfunction getMessageFromMessageID(msgId) {\r\n  var q = &quot;rfc822msgid:&quot; + msgId;\r\n  var threads = GmailApp.search(q);\r\n  if (threads.length &gt; 0) {\r\n    var messages = GmailApp.getMessagesForThread(threads&#x5B;0]);\r\n    if (messages.length &gt; 0) {\r\n      return messages&#x5B;0];\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u4e2d\u3005\u4f7f\u7528\u3059\u308b\u6a5f\u4f1a\u306f\u7121\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3054\u53c2\u8003\u307e\u3067\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<p><span style=\"color: #ff0000; font-weight: bold;\">2019\/5\/21 \u8ffd\u8a18\uff1a<\/span><br \/>\n2019\/5\/20\u4ed8\u3067\u8ffd\u52a0\u3055\u308c\u305f<a href=\"https:\/\/developers.google.com\/apps-script\/reference\/gmail\/gmail-message#getheadername\" title=\"Class GmailMessage  |  Apps Script  |  Google Developers\" target=\"_blank\" rel=\"noopener noreferrer\">GmailMessage.getHeader<\/a>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30d8\u30c3\u30c0\u30fc\u540d\u3092\u6307\u5b9a\u3059\u308b\u3060\u3051\u3067\u5024\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=11562\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Google-120x120.png' alt='[Google Apps Script]\u30d8\u30c3\u30c0\u30fc\u540d\u3092\u6307\u5b9a\u3057\u3066RFC 2822\u30d8\u30c3\u30c0\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2019.05.21<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=11562\">[Google Apps Script]\u30d8\u30c3\u30c0\u30fc\u540d\u3092\u6307\u5b9a\u3057\u3066RFC 2822\u30d8\u30c3\u30c0\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b <\/a><\/div><div class=\"cardlink_excerpt\">\u4ee5\u524d\u5f53\u30d6\u30ed\u30b0\u3067\u3001GAS\u3067\u30e1\u30fc\u30eb\u306eMessage-ID\u30d8\u30c3\u30c0\u30fc\u3092\u53d6\u5f97\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8(\u4e0b\u8a18\u8a18\u4e8b\u53c2\u7167)\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001Apps Script\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306b\u3088\u3063\u3066\u3001\u3088\u308a\u7c21\u5358\u306b\u30e1\u30fc\u30eb\u30d8\u30c3\u30c0\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\r\n\r\n\r\n\r\nGmailMessage....<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"\u306f\u3051\u305f(@excelspeedup)\u6c0f\u306e\u30c4\u30a4\u30fc\u30c8\u3067\u3001GAS\u3067\u30e1\u30fc\u30eb\u306eMessage-ID\u30d8\u30c3\u30c0\u30fc\u304c\u53d6\u5f97\u3067\u304d\u308b\u306e\u304b\uff1f\u3068\u3044\u3063\u305f\u5185\u5bb9\u306e\u3082\u306e\u304c\u3042\u308a\u307e\u3057\u305f\u3002 GAS\u3067\u30e1\u30fc\u30eb\u53d7\u4fe1\u306b\u9023\u52d5\u3057\u3066\u51e6\u7406\u3092\u3059\u308b\u4ed5\u7d44\u307f\u3092\u69cb\u7bc9\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u304d\u306b\u3001G [&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]\u30e1\u30fc\u30eb\u304b\u3089Message-ID\u30d8\u30c3\u30c0\u30fc\u3092\u53d6\u5f97\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-10760","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-2Ny","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10760","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=10760"}],"version-history":[{"count":5,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10760\/revisions"}],"predecessor-version":[{"id":11567,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10760\/revisions\/11567"}],"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=10760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}