If Send_Attachment <> "" Then Email.AddAttachment Send_Attachment '郵件附件 End If
With Email.Configuration.Fields .Item(MS_Space&"sendusing") = 2 '發(fā)信端口 .Item(MS_Space&"smtpserver") = "smtp."&You_ID(1) 'SMTP服務(wù)器地址 .Item(MS_Space&"smtpserverport") = 25 'SMTP服務(wù)器端口 .Item(MS_Space&"smtpauthenticate") = 1 'cdobasec .Item(MS_Space&"sendusername") = You_ID(0) '你的郵件帳號(hào) .Item(MS_Space&"sendpassword") = You_Password '你的郵件密碼 .Update End With Email.Send '發(fā)送郵件 Set Email=Nothing '關(guān)閉組件
Send_Mail=True '如果沒(méi)有任何錯(cuò)誤信息,則表示發(fā)送成功,否則發(fā)送失敗 If Err Then Err.Clear Send_Mail=False End If End Function
'以下是利用上面的函數(shù)發(fā)送帶附件的郵件例子 If Send_Mail("[email protected]","test","[email protected]","","郵件主題","郵件內(nèi)容","d:/test.exe")=True Then Wscript.Echo "發(fā)送成功" Else Wscript.Echo "發(fā)送失敗" End If