{"id":4044,"date":"2014-02-20T17:15:30","date_gmt":"2014-02-20T08:15:30","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=4044"},"modified":"2014-02-20T17:15:30","modified_gmt":"2014-02-20T08:15:30","slug":"%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a9%e3%83%ab%e3%83%80%e5%86%85%e3%81%aeeml%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e6%83%85%e5%a0%b1%e3%82%92%e3%83%aa%e3%82%b9%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=4044","title":{"rendered":"\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306eeml\u30d5\u30a1\u30a4\u30eb\u306e\u60c5\u5831\u3092\u30ea\u30b9\u30c8\u5316\u3059\u308bVBScript"},"content":{"rendered":"<p>eml\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u4ef6\u540d\u3084\u672c\u6587\u3001\u5b9b\u5148\u3084\u9001\u4fe1\u65e5\u6642\u3068\u3044\u3063\u305f\u5404\u7a2e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066\u8868\u306b\u307e\u3068\u3081\u308b\u51e6\u7406\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">'******************************************************\r\n' \u30c9\u30e9\u30c3\u30b0&amp;\u30c9\u30ed\u30c3\u30d7\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u3042\u308beml\u30d5\u30a1\u30a4\u30eb\u306e\r\n' \u60c5\u5831\u3092\u30ea\u30b9\u30c8\u5316\u3057\u3066Excel\u306b\u51fa\u529b\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\r\n' \r\n' 2014\/02\/20 @kinuasa\r\n'******************************************************\r\n\r\nOption Explicit\r\n\r\nDim Args\r\n\r\nSet Args = WScript.Arguments\r\n'\u30d1\u30e9\u30e1\u30fc\u30bf\u6570\u30c1\u30a7\u30c3\u30af\r\nIf Args.Count &lt; 1 Then\r\n  WScript.Echo &quot;\u5f53\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u30d5\u30a9\u30eb\u30c0\u3092\u30c9\u30e9\u30c3\u30b0&amp;\u30c9\u30ed\u30c3\u30d7\u3057\u3066\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;\r\n  WScript.Quit\r\nEnd If\r\n\r\n'\u30d5\u30a9\u30eb\u30c0\u5224\u5225\r\nWith CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n  If .FolderExists(Args(0)) = False Then\r\n    WScript.Echo &quot;\u30d5\u30a9\u30eb\u30c0\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002&quot; &amp; vbCrLf &amp; &quot;\u3042\u308b\u3044\u306f\u30d5\u30a9\u30eb\u30c0\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002&quot;\r\n    WScript.Quit\r\n  End If\r\nEnd With\r\n\r\n'eml\u30d5\u30a1\u30a4\u30eb\u306e\u6709\u7121\u30c1\u30a7\u30c3\u30af\r\nIf IsExistsParticularFile(Args(0), &quot;eml&quot;) = False Then\r\n  WScript.Echo &quot;\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306beml\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002&quot;\r\n  WScript.Quit\r\nEnd If\r\n\r\nListEmlFiles Args(0)\r\nWScript.Echo &quot;\u51e6\u7406\u304c\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002&quot;\r\n\r\nPrivate Sub ListEmlFiles(ByVal FolderPath)\r\n'\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306eeml\u30d5\u30a1\u30a4\u30eb\u306e\u60c5\u5831\u3092\u30ea\u30b9\u30c8\u5316(Excel)\r\n  Dim exApp\r\n  Dim exWb\r\n  Dim exWs\r\n  Dim msg\r\n  Dim f\r\n  Dim i\r\n  \r\n  Set exApp = CreateObject(&quot;Excel.Application&quot;)\r\n  exApp.Visible = True\r\n  Set exWb = exApp.Workbooks.Add\r\n  Set exWs = exWb.Worksheets(1)\r\n  i = 2 '\u521d\u671f\u5316\r\n\r\n  '\u898b\u51fa\u3057\r\n  exWs.Cells(1, 1).Value = &quot;No.&quot;\r\n  exWs.Cells(1, 2).Value = &quot;\u30d5\u30a1\u30a4\u30eb\u540d&quot;\r\n  exWs.Cells(1, 3).Value = &quot;\u4ef6\u540d&quot;\r\n  exWs.Cells(1, 4).Value = &quot;\u672c\u6587&quot;\r\n  exWs.Cells(1, 5).Value = &quot;\u9001\u4fe1\u8005&quot;\r\n  exWs.Cells(1, 6).Value = &quot;\u5b9b\u5148&quot;\r\n  exWs.Cells(1, 7).Value = &quot;\uff23\uff23&quot;\r\n  exWs.Cells(1, 8).Value = &quot;\uff22\uff23\uff23&quot;\r\n  exWs.Cells(1, 9).Value = &quot;\u9001\u4fe1\u65e5\u6642&quot;\r\n  exWs.Cells(1, 10).Value = &quot;\u53d7\u4fe1\u65e5\u6642&quot;\r\n  exWs.Cells(1, 11).Value = &quot;\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u6570&quot;\r\n  \r\n  With CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n    For Each f In .GetFolder(FolderPath).Files\r\n      Select Case LCase(.GetExtensionName(f))\r\n        'eml\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u51e6\u7406\r\n        Case &quot;eml&quot;\r\n          Set msg = GetMessage(f.Path)\r\n          exWs.Cells(i, 1).Value = i - 1\r\n          exWs.Cells(i, 2).Value = f.Name\r\n          exWs.Cells(i, 3).Value = msg.Subject\r\n          exWs.Cells(i, 4).Value = msg.TextBody\r\n          exWs.Cells(i, 5).Value = msg.From\r\n          exWs.Cells(i, 6).Value = msg.To\r\n          exWs.Cells(i, 7).Value = msg.CC\r\n          exWs.Cells(i, 8).Value = msg.BCC\r\n          exWs.Cells(i, 9).Value = msg.SentOn\r\n          exWs.Cells(i, 10).Value = msg.ReceivedTime\r\n          exWs.Cells(i, 11).Value = msg.Attachments.Count\r\n          Set msg = Nothing\r\n          i = i + 1\r\n      End Select\r\n    Next\r\n  End With\r\n  exWs.Range(exWs.Rows(2), exWs.Rows(i - 1)).WrapText = False\r\nEnd Sub\r\n\r\nPrivate Function GetMessage(ByVal FilePath)\r\n'eml\u30d5\u30a1\u30a4\u30eb\u304b\u3089Message\u53d6\u5f97\r\n  Dim stm\r\n  Dim msg\r\n  \r\n  Set stm = CreateObject(&quot;ADODB.Stream&quot;)\r\n  Set msg = CreateObject(&quot;CDO.Message&quot;)\r\n  stm.Open\r\n  stm.LoadFromFile FilePath\r\n  msg.DataSource.OpenObject stm, &quot;_Stream&quot;\r\n  stm.Close\r\n  Set GetMessage = msg\r\nEnd Function\r\n\r\nPrivate Function IsExistsParticularFile(ByVal FolderPath, ByVal FileExtension)\r\n'\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u7279\u5b9a\u306e\u62e1\u5f35\u5b50\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u304b\u3092\u8abf\u3079\u308b\r\n  Dim ret\r\n  Dim f\r\n  \r\n  ret = False '\u521d\u671f\u5316\r\n  With CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n    For Each f In .GetFolder(FolderPath).Files\r\n      Select Case LCase(.GetExtensionName(f))\r\n        Case LCase(FileExtension)\r\n          ret = True\r\n          Exit For\r\n      End Select\r\n    Next\r\n  End With\r\n  IsExistsParticularFile = ret\r\nEnd Function<\/pre>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u30c9\u30e9\u30c3\u30b0&#038;\u30c9\u30ed\u30c3\u30d7\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u3042\u308beml\u30d5\u30a1\u30a4\u30eb\u306e\u60c5\u5831\u3092\u3001\u30ea\u30b9\u30c8\u5316\u3057\u3066Excel\u306b\u51fa\u529b\u3059\u308b\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u30e1\u30fc\u30e9\u30fc\u306b\u6e9c\u307e\u3063\u305f\u30e1\u30fc\u30eb\u306e\u60c5\u5831\u3092\u307e\u3068\u3081\u308b\u306e\u306b\u5f79\u7acb\u3064\u30b9\u30af\u30ea\u30d7\u30c8\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h4>\u3010\u7de8\u96c6\u5f8c\u8a18\u3011<\/h4>\n<p>Outlook\u4ee5\u5916\u306e\u30e1\u30fc\u30e9\u30fc\u306b\u6e9c\u307e\u3063\u305f\u30e1\u30fc\u30eb\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\nCDO\u3092\u4f7f\u3046\u3068\u7c21\u5358\u306beml\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u60c5\u5831\u3092\u629c\u304d\u51fa\u305b\u308b\u306e\u3067\u3001\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u306d\uff01<br \/>\n\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u306f\u4e00\u90e8\u60c5\u5831\u3057\u304b\u53d6\u5f97\u3057\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u30b3\u30fc\u30c9\u3092\u4e00\u90e8\u5909\u66f4\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u4ed6\u306e\u30e1\u30fc\u30eb\u30d8\u30c3\u30c0\u30fc\u60c5\u5831\u3082\u629c\u304d\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"eml\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u4ef6\u540d\u3084\u672c\u6587\u3001\u5b9b\u5148\u3084\u9001\u4fe1\u65e5\u6642\u3068\u3044\u3063\u305f\u5404\u7a2e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3066\u8868\u306b\u307e\u3068\u3081\u308b\u51e6\u7406\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002 &#8216;****************************************************** &#8216; [&hellip;]","protected":false},"author":1,"featured_media":7132,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[],"class_list":["post-4044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vbs"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-VBScript.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-13e","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4044","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=4044"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4044\/revisions"}],"predecessor-version":[{"id":4045,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4044\/revisions\/4045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7132"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}