Asp.net用smtp寄出信件
Try
Dim newPassword As String = ""
newPassword = newPassword & ((Rnd() * 99) \ 1) & Chr(Rnd() * 25
+ 65) & ((Rnd() * 99) \ 1) & Chr(Rnd() * 25 + 65) & ((Rnd()
* 99) \ 1) & Chr(Rnd() * 25 + 65)
SqlDataSource1.UpdateParameters("id").DefaultValue = id
SqlDataSource1.UpdateParameters("name").DefaultValue = TextBox3.Text
SqlDataSource1.UpdateParameters("password").DefaultValue =
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword,
"SHA1")
SqlDataSource1.Update()
Dim To_Address As String = "admin@draco-online.com.tw"
Dim SMTP_Server As New SmtpClient("mail.draco-online.com.tw")
Dim Mailmsg As New System.Net.Mail.MailMessage
Dim MailBodyHtml As String
Mailmsg.BodyEncoding = Encoding.GetEncoding(950)
Mailmsg.SubjectEncoding = Encoding.GetEncoding(950)
Mailmsg.IsBodyHtml = True '為html內容格式
Mailmsg.Subject = "密碼變更"
Mailmsg.From = New Net.Mail.MailAddress("admin@draco-online.com.tw", "主題")
MailBodyHtml = "
"
MailBodyHtml &= "
"
Mailmsg.Body = MailBodyHtml
'=================================
For Each MA As String In To_Address.Split(";")
Mailmsg.To.Add(New Net.Mail.MailAddress(mail, "收件人"))
Next
'================================
'Mailmsg.Bcc.Add(New Net.Mail.MailAddress(mail, "藏鏡人"))
'Mailmsg.Priority = MailPriority.High
'SMTP_Server.Credentials = New System.Net.NetworkCredential("UserName", "Pwd") '認證
'Smtp(Server)
SMTP_Server.Send(Mailmsg)
Dim info As String = " " '動態建立JavaScript
If (Not Page.ClientScript.IsStartupScriptRegistered("Welcome")) Then '判斷myName是否已被註冊。
Page.ClientScript.RegisterStartupScript(Me.GetType(), "Welcome", info)
End If
Catch ex As Exception
Dim info As String = " " '動態建立JavaScript
If (Not Page.ClientScript.IsStartupScriptRegistered("Welcome")) Then '判斷myName是否已被註冊。
Page.ClientScript.RegisterStartupScript(Me.GetType(), "Welcome", info)
End If
End Try
留言列表