作成 2010.01.08
更新 2010.01.08
更新 2010.01.08
VBScript でメール送信
このサンプルではメールを送信します。添付ファイルも使用できます。
SMTP Auth を使用する際は以下のパラメータを同様に追加する。
Option Explicit
Const useLocalSMTPService = 1
Const useRemoteSMTPService = 2
Const useLocalExchangeService = 3
Dim objMessage
Dim mySMTPServer
Dim mySMTPPort
Dim myAttachment
mySMTPServer = "mail.example.lan"
mySMTPPort = 25
myAttachment = "C:\append.txt"
Set objMessage = CreateObject("CDO.Message")
objMessage.From = "mail_from@example.lan"
objMessage.To = "mail_to@example.lan"
objMessage.Subject = "Test vbs"
objMessage.TextBody = "テストメッセージです" & vbCrLf & Now
objMessage.AddAttachment(myAttachment)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = useRemoteSMTPService
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mySMTPServer
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = mySMTPPort
objMessage.Configuration.Fields.Update
objMessage.Send
MsgBox "送信完了"
補足SMTP Auth を使用する際は以下のパラメータを同様に追加する。
"http://schemas.microsoft.com/cdo/configuration/sendusername" "http://schemas.microsoft.com/cdo/configuration/sendpassword"
タグ: VBScript