-1
我正在使用vb.net和asp.net。我想發送一個簡單的文本到我的數據庫中存在的電子郵件地址。我已經聲明瞭文本並可以從我的數據庫中獲取電子郵件地址。但我不知道如何將文本發送到特定的電子郵件地址。請幫助。感謝如何發送電子郵件到數據庫中存在的電子郵件地址
我正在使用vb.net和asp.net。我想發送一個簡單的文本到我的數據庫中存在的電子郵件地址。我已經聲明瞭文本並可以從我的數據庫中獲取電子郵件地址。但我不知道如何將文本發送到特定的電子郵件地址。請幫助。感謝如何發送電子郵件到數據庫中存在的電子郵件地址
使用此功能VB.Net:
Public Shared Function sendmail(ByVal to As String, ByVal subject As String, ByVal body As String, ByVal IsBodyHtml As Boolean) As Integer
Dim mm As New MailMessage("[email protected]", to)
mm.Subject = subject
mm.Body = body
mm.IsBodyHtml = IsBodyHtml
Dim smtp As New SmtpClient
Try
smtp.Send(mm)
Return 1
Catch ex As Exception
Return 0
End Try
End Function
在你的web.config:
<configuration>
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.youremailservice.com"
userName="[email protected]"
password="yourpassword"/>
</smtp>
</mailSettings>