0
以下は、ファイルが添付された電子メールを送信する私のVBScriptコードです。このファイルは、電子メールを送信するときに取得する必要がある場所に存在します。私が使用して、コマンドラインからこのスクリプトを実行するにはコマンドラインからファイルの場所を渡す
Set objMessage = CreateObject("CDO.Message")
Set args = WScript.Arguments
Set arg1 = args.Item(0)
objMessage.Subject = "Sample subject"
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "Please see the error logs attached with this email"
objMessage.AddAttachment ""&arg1&""
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "hostname"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
:
>cscript sendemail.vbs D:\users\me\Desktop\readme.txt
私はこれを実行すると、私は言ってエラーを取得:
D:\Users\me\Desktop\sendemail.vbs(3, 1) Microsoft VBScript runtime error: Object required: '[string: "D:\Users\me\Desk"]'
任意の提案はこれで間違って何ができますか?
'objMessage.AddAttachment args(0)' – Squashman
私はあなたが言ったことを試しましたが、それは私に同じ正確なエラーを与えます。 – JohnG
が奇妙です。それは私がvbscriptですべての電子メールをやりとりする方法です。私はそれに引数としてすべてを渡す一般的なvbscriptを使用します。 – Squashman