{"id":7459,"date":"2016-10-12T14:09:57","date_gmt":"2016-10-12T05:09:57","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7459"},"modified":"2020-05-17T16:35:16","modified_gmt":"2020-05-17T07:35:16","slug":"cdo%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6gmail%e9%80%81%e4%bf%a1%e3%82%92%e8%a1%8c%e3%81%86vba%e3%83%9e%e3%82%af%e3%83%adutf-8%e5%af%be%e5%bf%9c%e7%89%88","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=7459","title":{"rendered":"CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed(UTF-8\u5bfe\u5fdc\u7248)"},"content":{"rendered":"<p>2\u5e74\u307b\u3069\u524d\u306bCDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed\u306b\u3064\u3044\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=4730\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA-120x120.png' alt='CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2014.08.11<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=4730\">CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u300cVBA Gmail \u9001\u4fe1\u300d\u3068\u3044\u3063\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3067\u3001\u300cGmail API\u3092\u4f7f\u3063\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308bVBA\u30de\u30af\u30ed(3)\u300d\u306e\u8a18\u4e8b\u306b\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002\r\n\r\n\u305f\u3057\u304b\u306bGmail API\u3092\u4f7f\u3063\u3066VBA\u30de\u30af\u30ed\u304b\u3089\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u3059\u3002\r\n\u30fb\u30fb\u30fb\u304c\u3001VBA\u304b\u3089G...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n<p>\u305d\u3057\u3066\u5148\u65e5\u3001\u3053\u306e\u30de\u30af\u30ed\u306b\u5bfe\u3057\u3066\u300cUTF-8\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3067\u304d\u306a\u3044\u304b\uff1f\u300d\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308b\u3053\u3068\u306b\u6c17\u304c\u4ed8\u304d\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u30a8\u30af\u30bb\u30eb\u304b\u3089gmail\u3067\u306e\u9001\u4fe1<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/excelfactory.net\/excelboard\/excelvba\/excel.cgi?mode=all&#038;namber=178509&#038;rev=0\" target=\"_blank\" title=\"\u30a8\u30af\u30bb\u30eb\u304b\u3089gmail\u3067\u306e\u9001\u4fe1\" rel=\"noopener noreferrer\">http:\/\/excelfactory.net\/excelboard\/excelvba\/excel.cgi?mode=all&#038;namber=178509&#038;rev=0<\/a><\/li>\n<\/ul>\n<p>\u306a\u308b\u307b\u3069\u3002<br \/>\n\u305f\u3057\u304b\u306b\u5148\u306e\u8a18\u4e8b\u3067\u306f\u30e1\u30fc\u30eb\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u306b\u3064\u3044\u3066\u610f\u8b58\u3057\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\u3001\u4e0a\u8a18Q&#038;A\u30da\u30fc\u30b8\u306e\u56de\u7b54\u306b\u3082\u3042\u308b\u3088\u3046\u306b\u3001BodyPart\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eCharset\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u9001\u4fe1\u3059\u308b\u30e1\u30fc\u30eb\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u30b3\u30fc\u30c9\u306f\u3001<a href=\"https:\/\/www.ka-net.org\/blog\/?p=4730\" title=\"CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\" rel=\"noopener noreferrer\">\u4ee5\u524d\u66f8\u3044\u305f\u8a18\u4e8b\u306e\u30b3\u30fc\u30c9<\/a>\u306b\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u300c<span style=\"color: #ff0000; font-weight: bold;\">MailCharset<\/span>\u300d\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u305f\u3082\u306e\u3067\u3001\u7279\u306b\u6307\u5b9a\u304c\u7121\u3044\u5834\u5408\u306f\u300ciso-2022-jp\u300d\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n \r\nPublic Sub Sample()\r\n  SendGmail &quot;(Google \u30a2\u30ab\u30a6\u30f3\u30c8)@gmail.com&quot;, _\r\n            &quot;(Google \u30a2\u30ab\u30a6\u30f3\u30c8 \u30d1\u30b9\u30ef\u30fc\u30c9)&quot;, _\r\n            &quot;(To\u30a2\u30c9\u30ec\u30b9)&quot;, _\r\n            &quot;(Cc\u30a2\u30c9\u30ec\u30b9)&quot;, _\r\n            &quot;(Bcc\u30a2\u30c9\u30ec\u30b9)&quot;, _\r\n            &quot;\u4ef6\u540d\uff1a\u30e1\u30fc\u30eb\u30c6\u30b9\u30c8&quot;, _\r\n            ChrW(&amp;H4F60) &amp; ChrW(&amp;H597D) &amp; vbCrLf &amp; &quot;\u3042\u3044\u3046\u3048\u304a&quot; &amp; vbCrLf &amp; &quot;\u304b\u304d\u304f\u3051\u3053&quot;, _\r\n            &quot;utf-8&quot;\r\nEnd Sub\r\n\r\nPrivate Sub SendGmail(ByVal AccountAddress As String, _\r\n                      ByVal AccountPassword As String, _\r\n                      ByVal MailTo As String, _\r\n                      ByVal MailCc As String, _\r\n                      ByVal MailBcc As String, _\r\n                      ByVal MailSubject As String, _\r\n                      ByVal MailBody As String, _\r\n                      Optional ByVal MailCharset As String = &quot;iso-2022-jp&quot;, _\r\n                      Optional ByVal AttachmentFilePath As String = &quot;&quot;)\r\n'CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046\r\n  Const cdoBasic = 1\r\n  Const cdoSendUsingPort = 2\r\n  Const cdoSendPassword = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendpassword&quot;\r\n  Const cdoSendUserName = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusername&quot;\r\n  Const cdoSendUsingMethod = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/sendusing&quot;\r\n  Const cdoSMTPConnectionTimeout = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpconnectiontimeout&quot;\r\n  Const cdoSMTPServer = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserver&quot;\r\n  Const cdoSMTPServerPort = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpserverport&quot;\r\n  Const cdoSMTPUseSSL = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpusessl&quot;\r\n  Const cdoSMTPAuthenticate = &quot;http:\/\/schemas.microsoft.com\/cdo\/configuration\/smtpauthenticate&quot;\r\n  \r\n  'Charset\u8a2d\u5b9a\r\n  MailCharset = LCase(StrConv(MailCharset, vbNarrow))\r\n  Select Case MailCharset\r\n    Case &quot;big5&quot;, &quot;euc-jp&quot;, &quot;euc-kr&quot;, &quot;gb2312&quot;, &quot;iso-2022-jp&quot;, _\r\n         &quot;iso-2022-kr&quot;, &quot;iso-8859-1&quot;, &quot;iso-8859-2&quot;, &quot;iso-8859-3&quot;, &quot;iso-8859-4&quot;, _\r\n         &quot;iso-8859-5&quot;, &quot;iso-8859-6&quot;, &quot;iso-8859-7&quot;, &quot;iso-8859-8&quot;, &quot;iso-8859-9&quot;, _\r\n         &quot;koi8-r&quot;, &quot;shift-jis&quot;, &quot;us-ascii&quot;, &quot;utf-7&quot;, &quot;utf-8&quot;\r\n    Case Else: MailCharset = &quot;shift-jis&quot;\r\n  End Select\r\n  \r\n  With CreateObject(&quot;CDO.Message&quot;)\r\n    .From = AccountAddress\r\n    .To = MailTo\r\n    .BodyPart.Charset = MailCharset\r\n    If Len(Trim(MailCc)) &gt; 0 Then .CC = MailCc\r\n    If Len(Trim(MailBcc)) &gt; 0 Then .BCC = MailBcc\r\n    .Subject = MailSubject\r\n    .TextBody = MailBody\r\n    If Len(Trim(AttachmentFilePath)) &gt; 0 Then .AddAttachment AttachmentFilePath\r\n    With .Configuration.Fields\r\n      .Item(cdoSendPassword).Value = AccountPassword\r\n      .Item(cdoSendUserName).Value = AccountAddress\r\n      .Item(cdoSendUsingMethod).Value = cdoSendUsingPort\r\n      .Item(cdoSMTPConnectionTimeout).Value = 100\r\n      .Item(cdoSMTPAuthenticate).Value = cdoBasic\r\n      .Item(cdoSMTPServer).Value = &quot;smtp.gmail.com&quot;\r\n      .Item(cdoSMTPServerPort).Value = 465\r\n      .Item(cdoSMTPUseSSL).Value = True\r\n      .Update\r\n    End With\r\n    On Error Resume Next\r\n    .Send\r\n    If Err.Number &lt;&gt; 0 Then\r\n      MsgBox &quot;\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002&quot; &amp; vbCrLf &amp; _\r\n             &quot;\u30a8\u30e9\u30fc\u756a\u53f7\uff1a&quot; &amp; Err.Number &amp; vbCrLf &amp; _\r\n             &quot;\u30a8\u30e9\u30fc\u5185\u5bb9\uff1a&quot; &amp; Err.Description, vbCritical + vbSystemModal\r\n    End If\r\n    On Error GoTo 0\r\n  End With\r\nEnd Sub<\/pre>\n<p>\u4e0a\u8a18Sample\u30de\u30af\u30ed\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4e0b\u56f3\u306e\u901a\u308a\u30e1\u30fc\u30eb\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u304cUTF-8\u306b\u306a\u308a\u3001\u4e2d\u56fd\u8a9e\u3082\u554f\u984c\u7121\u304f\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/SendGmailCDO_02.jpg\" alt=\"sendgmailcdo_02\" width=\"680\" height=\"496\" class=\"alignnone size-full wp-image-7460\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/SendGmailCDO_02.jpg 680w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/SendGmailCDO_02-300x219.jpg 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>\u30e1\u30fc\u30eb\u9001\u4fe1\u6642\u306b\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u3092\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\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<hr \/>\n<p><span style=\"color: #ff0000; font-weight: bold;\">2020\/5\/17 \u8ffd\u8a18\uff1a<\/span><br \/>\n\u300c<a href=\"https:\/\/gsuiteupdates-ja.googleblog.com\/2019\/12\/g-suite_24.html\" title=\"G Suite \u30a2\u30c3\u30d7\u30c7\u30fc\u30c8 \u30d6\u30ed\u30b0: \u5b89\u5168\u6027\u306e\u4f4e\u3044\u30a2\u30d7\u30ea\u306b\u3088\u308b G Suite \u30a2\u30ab\u30a6\u30f3\u30c8\u3078\u306e\u63a5\u7d9a\u304c\u7121\u52b9\u306b\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b89\u5168\u6027\u306e\u4f4e\u3044\u30a2\u30d7\u30ea<\/a>\u300d\u306b\u3088\u308bGmail\u9001\u4fe1\u304c\u3067\u304d\u306a\u304f\u306a\u308b\u4e88\u5b9a\u3067\u3042\u308b\u305f\u3081\u3001Outlook\u3092\u4f7f\u3046\u30de\u30af\u30ed\u306b\u3064\u3044\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=12806\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA-120x120.png' alt='Outlook\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2020.05.17<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=12806\">Outlook\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u4e0b\u8a18G Suite \u30a2\u30c3\u30d7\u30c7\u30fc\u30c8 \u30d6\u30ed\u30b0\u306b\u3042\u308b\u901a\u308a\u3001\u4eca\u5e74\u306e6\u6708\u306b\u306f\u201c\u5b89\u5168\u6027\u306e\u4f4e\u3044\u30a2\u30d7\u30ea\u201d\u306b\u3088\u308bGmail\u3084\u30ab\u30ec\u30f3\u30c0\u30fc\u3068\u3044\u3063\u305fGoogle\u306e\u30b5\u30fc\u30d3\u30b9\u306b\u65b0\u898f\u63a5\u7d9a\u304c\u3067\u304d\u306a\u304f\u306a\u308a\u30012021\u5e742\u6708\u306b\u306f\u3001\u5b89\u5168\u6027\u306e\u4f4e\u3044\u30a2\u30d7\u30ea\u3078\u306e\u63a5\u7d9a\u306f\u3059\u3079\u3066\u7121\u52b9\u306b\u306a\u308a\u307e\u3059\u3002\r\n\r\n\r\n\r\n\u5f53...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"2\u5e74\u307b\u3069\u524d\u306bCDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed\u306b\u3064\u3044\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u5148\u65e5\u3001\u3053\u306e\u30de\u30af\u30ed\u306b\u5bfe\u3057\u3066\u300cUTF-8\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3067\u304d\u306a\u3044\u304b\uff1f\u300d\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308b\u3053\u3068\u306b\u6c17\u304c\u4ed8\u304d\u307e\u3057\u305f\u3002 \u30a8\u30af\u30bb\u30eb\u304b\u3089gmail\u3067\u306e [&hellip;]","protected":false},"author":1,"featured_media":7120,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Charset\u3082\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002 [CDO\u3092\u4f7f\u3063\u3066Gmail\u9001\u4fe1\u3092\u884c\u3046VBA\u30de\u30af\u30ed(UTF-8\u5bfe\u5fdc\u7248)]","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":[4,48,49,58,126],"tags":[],"class_list":["post-7459","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-powerpoint","category-google"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeVBA.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1Wj","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7459","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=7459"}],"version-history":[{"count":5,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7459\/revisions"}],"predecessor-version":[{"id":12811,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7459\/revisions\/12811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7120"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}