2012-08-15 2 views
-1

vb.net 및 asp.net을 사용하고 있습니다. 내 데이터베이스에있는 이메일 주소로 간단한 텍스트를 보내고 싶습니다. 나는 이미 텍스트를 선언하고 내 데이터베이스에서 이메일 주소를 얻을 수 있습니다. 하지만 특정 이메일 주소로 텍스트를 보내는 방법을 모르겠습니다. 도와주세요. 감사데이터베이스에있는 이메일 주소로 이메일을 보내는 방법

답변

1

사용이 VB.Net 기능 : 당신의 Web.config에

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 

:

<configuration> 
<system.net> 
<mailSettings> 
    <smtp from="[email protected]"> 
    <network host="smtp.youremailservice.com" 
       userName="[email protected]" 
       password="yourpassword"/> 
    </smtp> 
</mailSettings> 
관련 문제