VBSTips

メール送信

' 「cscript バッチファイル名」 で実行する。
' 参考URL:http://www.atmarkit.co.jp/fwin2k/win2ktips/428wshmail/wshmail.html
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "[送信元アドレス:xxx@xxx.xx.xx]"
oMsg.To = "[宛先アドレス:xxx@xxx.xx.xx]"
' CC,BCCがある場合は、以下を設定してください。
'oMsg.cc  = "xxx@xxx.xx.xx"
'oMsg.bcc = "xxx@xxx.xx.xx"
oMsg.Subject = "[タイトル:バッチ送信テスト]"
oMsg.TextBody = "[本文]"                       ' 例:"テストメッセージです" & vbCrLf & Now
oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") _
   = 2
oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
   = "[smtpサーバ:smtp.xxx.xx.xx]"
oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
   = [通信ポート:25]
oMsg.Configuration.Fields.Update
' 添付ファイルがある場合は「oMsg.AddAttachment」の引数に指定してください。
' 1回で添付できるのは1ファイルなので、複数ファイルある場合は、複数回実行してください。
'oMsg.AddAttachment "[添付ファイル名:x:\test.txt]"
oMsg.Send
最終更新:2008年08月28日 08:37