Source code:
Imports System.Web.MailPublic Class testemail1
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button#Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Send("[email protected]", "[email protected]", "[email protected]", "test email", "asfsf text", MailPriority.High)
End Sub
Public Sub Send(ByVal FromUser As String, ByVal ToUser As String, ByVal CCUser As String, ByVal Subject As String, _
ByVal Body As String, Optional ByVal Importance As MailPriority = MailPriority.Normal)
Dim mailObj As New MailMessage()
Dim smtp As SmtpMail smtp.SmtpServer = "hqsntw3736"
mailObj.From = FromUser
mailObj.To = ToUser
mailObj.Cc = CCUser mailObj.Subject = Subject
mailObj.Body = Body
mailObj.BodyFormat = MailFormat.Html mailObj.Priority = Importance
smtp.Send(mailObj) mailObj = Nothing
smtp = Nothing
End Sub
End Class
Imports System.Web.MailPublic Class testemail1
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button#Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Send("[email protected]", "[email protected]", "[email protected]", "test email", "asfsf text", MailPriority.High)
End Sub
Public Sub Send(ByVal FromUser As String, ByVal ToUser As String, ByVal CCUser As String, ByVal Subject As String, _
ByVal Body As String, Optional ByVal Importance As MailPriority = MailPriority.Normal)
Dim mailObj As New MailMessage()
Dim smtp As SmtpMail smtp.SmtpServer = "hqsntw3736"
mailObj.From = FromUser
mailObj.To = ToUser
mailObj.Cc = CCUser mailObj.Subject = Subject
mailObj.Body = Body
mailObj.BodyFormat = MailFormat.Html mailObj.Priority = Importance
smtp.Send(mailObj) mailObj = Nothing
smtp = Nothing
End Sub
End Class
解决方案 »
- js调用webservice的问题~~~~
- 简单的问题 在线等 datalist 显示详情
- 谁写过enom注册系统的。
- (正则表达式)过客 者正则表达式高手来帮忙解决下效率问题
- datagrid分页的情况下,导出生成excel??????请各位大侠指教
- 静态类的生存周期是?静态变量的赋值问题?请赐教~
- Asp.net mvc如何实现的模板引擎如何实现以下需求?
- 请大家给个建议~
- HyperlinkColumn要传两个列值并用Javascript打开新window?
- 如何定制-屏蔽多个不固定的词汇阿?问题很低级,不许笑话我啊
- 如何能最简实现全文检索?
- 请帮助我(有关solpartwebcontrol)!
另外有些mailserver有限制的,可以换别的smtpserver试试看
I have used "localhost" but it also encouter the same problem.
thanks!
I'v got it.
I need setting the smtp server first.
Here are the steps, I did.1. In IIS right-click on the Default SMTP Virtual Server and select Properties.
2. In the Properties dialog box, selec the Access tab.
3. Click on the Relay button.
4. In the Relay Restrictions dialog box, select the Allow except the list below radio button.