2012-10-16 52 views
0

我必須發送一封簡單的郵件給申請人,才能成功提交表單。什麼是vb中的代碼來做到這一點? 我一直想這個..通過VBSCRIPT發送電子郵件

function email() 
    Set mailObj=CreateObject("CDO.Message") 
     mailObj.Subject="Hello" 
     mailObj.From="[email protected]" 
     mailObj.To="[email protected]" 
     mailObj.TextBody="text" 
     mailObj.Send 
    set mailObj=nothing 
end function 

有沒有在代碼中的一些問題嗎?請糾正..

+0

在運行時遇到任何問題嗎?如果這樣的話。如果您在帖子中沒有清楚地提到所有問題,我們如何理解您是否面臨任何問題或錯誤? –

+0

不,但我沒有收到任何郵件在收件人列中指定的電子郵件ID ...運行此操作時沒有錯誤,只是我無法發送電子郵件 – Coder1010

回答

3

使用類似於下面的東西。

Set objEmail = CreateObject("CDO.Message") 
objEmail.From = "[email protected]" 
objEmail.To = "[email protected]" 

objEmail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
objEmail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ 
    "your.smtpserver.here" 
objEmail.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
objEmail.Configuration.Fields.Update 

objEmail.TextBody = "The body of the email" 
objEmail.Subject = "The subject" 

objEmail.Send 
+0

這是什麼your.smtpserver.here? 意味着要寫什麼來代替這個? – Coder1010

+0

在這裏,您將放置要用來發送電子郵件的SMTP服務器的IP或DNS名稱。 – jagsler