2011-02-01 259 views

回答

12

使用SmtpClient class within the System.Net.Mail namespace

示例。

'create the mail message 
Dim mail As New MailMessage() 

'set the addresses 
mail.From = New MailAddress("[email protected]") 
mail.[To].Add("[email protected]") 

'set the content 
mail.Subject = "This is an email" 
mail.Body = "this is a sample body" 

'set the server 
Dim smtp As New SmtpClient("localhost") 

'send the message 
Try 
    smtp.Send(mail) 
    Response.Write("Your Email has been sent sucessfully - Thank You") 
Catch exc As Exception 
    Response.Write("Send failure: " & exc.ToString()) 
End Try 
+0

代碼將在Microsoft交換服務器上運行。我需要做不同的事情嗎? – Beginner 2011-02-01 13:01:11

2

您可以使用System.Net.Mail命名空間,查看它並查看它是否有幫助。我使用C#,但我想它是類似的,創建一個客戶端,然後一條消息,設置消息的參數,然後client.Send()將發送消息。