質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
VBScript

VBScript(Visual Basic Scripting Edition)はMicrosftが開発したスクリプト言語であり、Visual Basicのサブセットです。

Q&A

2回答

26496閲覧

Win7→Win10になったら VB Script でメールが送れなくなりました。

it_solution_lab

総合スコア71

VBScript

VBScript(Visual Basic Scripting Edition)はMicrosftが開発したスクリプト言語であり、Visual Basicのサブセットです。

0グッド

0クリップ

投稿2018/07/21 16:12

下記、プログラムで
windows7 では home版でもpro版でも 正しくメール送信されていたのですが、
windows10 pro にしたところ動作せず、エラーが出るようになりました。
5月下旬ころまでは動作していたのですが、PCを変更して7月21日に
動作確認したら動作しなくなっておりました

OSのバージョン違いによるものなのか?
PCを変えたために、PC側に何かインストールや設定変更しないと
動作しないのか?
gmailの仕様が変更になったのか?

動かなくなった原因が不明で困っています

どなたか原因や解決策がわかる方、コメントいただけたら幸いです。

Set objMail = CreateObject("CDO.Message") objMail.From = "testaddress@gmail.com" objMail.To = "tomail@gmail.com" objMail.Subject = "■送信テスト■" objMail.TextBody = "テスト送信です" & vbCrLf & "確認お願いします" & vbCrLf & " " & vbCrLf & " " & vbCrLf & " " & "送信日時:" & Now objMail.AddAttachment "C:\Users\user\Desktop\xxx\添付ファイル.zip" strConfigurationField ="http://schemas.microsoft.com/cdo/configuration/" With objMail.Configuration.Fields .Item(strConfigurationField & "sendusing") = 2 .Item(strConfigurationField & "smtpserver") = "smtp.gmail.com" .Item(strConfigurationField & "smtpserverport") = 465 .Item(strConfigurationField & "smtpusessl") = true .Item(strConfigurationField & "smtpauthenticate") = 1 .Item(strConfigurationField & "sendusername") = "testaddress@gmail.com" .Item(strConfigurationField & "sendpassword") = "testpasword" .Item(strConfigurationField & "smtpconnectiontimeout") = 60 .Update end With objMail.Send Set objMail = Nothing

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

otn

2018/07/21 21:04

「動作しない」とは?実行した際の現象は何ですか?
guest

回答2

0

未解決です

Windows 10 Pro 64bit 上の
Microsoft (R) Windows Script Host Version 5.812 (.vbsファイルにしてダブルクリック)
およびVBA 7.1 64bit(MS Office 64bitのVBA)
で試してみました。

当初は記載のコードでは以下のエラーが発生していました(VBAで実行した場合のエラーメッセージ)。

ErrorMessage
-2147220975
メッセージを SMTP サーバーに送信できませんでした。転送エラー コードは 0x80040217 です。サーバーからの応答は次のとおりです。not available

しかし、何度か試しているうちにあるタイミングから成功するようになってしまいました。
そのため何が原因だったのか特定できていません。

念のため、私が成功した際のコードを記載しておきます。

vbscript

1'https://teratail.com/questions/137189 2Option Explicit 3 4Const FromAddress = "testaddress@gmail.com" 5Const ToAddress = "tomail@gmail.com" 6Const AttachPath = "C:\Users\user\Desktop\xxx\添付ファイル.zip" 7Const PassWord = "testpasword" 8 9 10Dim objMail 'As CDO.Message 11Set objMail = CreateObject("CDO.Message") 12 13objMail.From = FromAddress 14objMail.To = ToAddress 15objMail.Subject = "■送信テスト■" 16objMail.TextBody = "テスト送信です" & vbCrLf & "確認お願いします" & vbCrLf & " " & vbCrLf & " " & vbCrLf & " " & "送信日時:" & Now 17objMail.AddAttachment AttachPath 18 19 20'IMAP を使用して他のメール クライアントで Gmail をチェックする - Gmail ヘルプ 21'https://support.google.com/mail/answer/7126229 22 23'http://www.atmarkit.co.jp/ait/articles/0405/22/news017.html 24Const sendUsingLocalSmtp = 1, sendUsingNetworkSmtp = 2, sendUsingExchange = 3 25'serialty.blog117.fc2.com/blog-entry-10.html 26Const smtpAuthTypeBasic = 1, smtpAuthTypeNTLM = 2 27 28'https://support.google.com/mail/answer/7126229 29Const gmailSmptSever = "smtp.gmail.com" 30Const gmailSmtpPortSSL = 465, gmailSmtpPortTLS = 587 31 32 33Const strConfigurationField = "http://schemas.microsoft.com/cdo/configuration/" 34With objMail.Configuration.Fields 35 .Item(strConfigurationField & "sendusing") = sendUsingNetworkSmtp 36 .Item(strConfigurationField & "smtpserver") = gmailSmptSever 37 .Item(strConfigurationField & "smtpserverport") = gmailSmtpPortSSL 38 .Item(strConfigurationField & "smtpusessl") = True 39 .Item(strConfigurationField & "smtpauthenticate") = smtpAuthTypeBasic 40 .Item(strConfigurationField & "sendusername") = FromAddress 41 .Item(strConfigurationField & "sendpassword") = PassWord 42 .Item(strConfigurationField & "smtpconnectiontimeout") = 60 43 .Update 44End With 'objMail.Configuration.Fields 45 46Call objMail.Send 47

投稿2018/07/22 00:35

imihito

総合スコア2166

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

MasahikoHirata

2018/07/22 02:16

まずエラーの内容から検索してみました。類似の問題が https://stackoverflow.com/questions/23224631/vbscript-error-80040211-when-sending-emails で見つかり、内容としてSMTP接続に失敗していて、まずはtelnetでsmtpに接続できるかを試してみる、もしそれで接続出来たらコードの問題ではなくSMTPの設定側ではとの内容です。SMTPサーバーの設定を最初に確認し、問題がないかを調べましょう。
guest

0

VB ScriptをIE11で使用していませんか?
まずIEのバージョンを確認してみてください。

またWin10 proのビルドをマイコンピューターのプロパティで確認も。

条件によって使用できないので。

参考サイト
さよなら、VBScript - 阿久津良和のWindows Weekly Report

投稿2018/07/21 17:45

MasahikoHirata

総合スコア3747

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問