我有一個vbscript,它將文件夾內容作爲附件發送到我的電子郵件,但問題是我無法指定windows文件夾的路徑,因爲不同計算機的windows路徑不同。在VBScript中指定windows文件夾路徑
在我的代碼如下工作
Const PATH = "C:\windows\Folder1\"
但由於路徑是不同的機器不同。我嘗試以下,但沒有成功
Const PATH = "%windows%\Folder1\"
以下是完整的VBScript代碼
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFolder
Dim oFile
Dim oFiles
Const PATH = "%windows%\Folder\" 'This method not working!!!!!
Set oFolder = fso.GetFolder(PATH)
Set oFiles= oFolder.files
objMessage.Subject = "This is the email subject"
objMessage.From = "[email protected]"
objMessage.To = ""
objMessage.TextBody = "This is the body of the email. I’m fairly unoriginal"
For Each oFile in oFolder.files
objMessage.AddAttachment PATH & oFile.name
Next
'==This section will provide the configuration information for the remote SMTP server.
'==End remote SMTP server configuration section==
objMessage.Send
當遠程SMTP服務器的配置信息的代碼完美的作品。
我將如何在此腳本中指定窗口,程序文件,桌面(特殊文件夾)?
那麼我的腳本應該是什麼樣子。對不起,我是vb腳本的初學者,請說明你的代碼需要放在哪裏? –
@AidenJones - 查看更新。 –
感謝您的答覆。我感謝您的示例用法,你瞭解我,但正如我所提到的我是一個初學者,我試圖適應你的代碼,但我每次都會收到錯誤,例如「expect fso」。請編輯我的代碼並提及它在你的回覆。提醒:我的腳本工作正常,將文件夾的內容附加到電子郵件,但「窗口,程序文件等」的路徑顯然是問題,因爲它改變了不同的pc.seriously它會解決我的挫折周!謝謝。 ;) –