お願いします。
vbsをbatファイルで呼び出し、メール送信を行っています。
その際、Z:\test フォルダのファイルを添付して送っています。
今回、添付したいファイルが複数になり、Z:\testフォルダにある
すべてのファイルを添付したいのですが、vbsをどのように変更すれば
良いのかわかりません。ご指導お願いいたします。
以下のコードは、検索してサイトから使わせていただいているものです。
Dim Fs, strPath, Fl, F, NewFile, NewFileFP, OutF
Set Fs = CreateObject("Scripting.FileSystemObject")
strPath = "Z:\test"
NewFile = ""
Set Fl = Fs.GetFolder(strPath)
For Each F In Fl.Files
If F.Name > NewFile Then
NewFile = F.Name
End If
Next
NewFileFP = Fl & "\" & NewFile
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "送信者 <test@xxxx.com>" '送信元
oMsg.To = "受信1 様 <jyusin1@xxxx.com>" '送信先
oMsg.Cc = "受信2 様 <jyusin2@xxxx.com>"
oMsg.Bcc = ""
oMsg.Subject = "TEST送信" '件名
oMsg.TextBody = "各位" & vbCrLf & vbCrLf & "テスト送信です。" 'メール本文
oMsg.AddAttachment NewFileFP '添付
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.xxxx.jp"
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx@xxxx.com"
oMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMsg.Configuration.Fields.Update
oMsg.Send
Set OutF = Fs.OpenTextFile("C:\mail\send.log",8)
OutF.WriteLine "Date[" & date & "] Time[" & time & "] File[" & NewFile & "]"
OutF.Close
Fs.DeleteFile NewFileFP
objShell.Popup "メール送信しました。", 0, "送信完了", 0
Set Fs = Nothing
Set Fl = Nothing
Set OutF = Nothing