maruton's memorandum
ここはブログ作成時にやったことのメモや今まで作ったスクリプトなどをおぼえがき程度にまとめておくところ。
ページ
ホーム
Blogger Tips
HTML Tips
Script
Windows Tools
OS Tips
IT日記
WordPress
Security
Other
★
プライバシーポリシー
ページ
暗号通貨でサポート
カルダノSPO
Amazonほしい物リスト
2013年7月2日火曜日
[Script][VBS]メールを送る(CDO.Message)
VB Script でメールの送信を行います。
CDO コンポーネントを使って Message オブジェクトに From や To のアドレス、メッセージ文をセット、Configuration パラメータをセットとアップデートをしたのち、Send メソッドでメールを送信します。
添付ファイルを送ることもできます。
メール送信サンプル(CDO.Message)
mail_send()
Sub mail_send
'------------------variable----------------------
Dim oMsg
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "from@mail.server.com"
oMsg.To = "to@maill.server.com"
oMsg.Subject = "Title"
oMsg.TextBody = "Message"
'添付ファイルを使う場合、コメントをはずす
' oMsg.AddAttachment("D:\file.txt")
' MailServer = "mail.server.com"
MailServer = "192.168.0.1"
'------------------------------------------------
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailServer
oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMsg.Configuration.Fields.Update
oMsg.Send
Set oMsg = Nothing
End Sub
※SMTP Auth は追加の設定で対応可能。
Script のページに戻る
0 件のコメント:
コメントを投稿
次の投稿
前の投稿
ホーム
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿