내 데이터베이스를 이메일 시스템에 연결하는 데 문제가 있습니다. 데이터베이스 연결과 SqlDataSource
연결을 설정했지만, 데이터베이스에 저장된 전자 메일로 전자 메일을 보내려는 경우 aspx.cs 페이지에서이를 참조하는 방법을 잘 모릅니다. 다른 사람이 이미 주석으로SQL Server 데이터베이스를 전자 메일 시스템에 어떻게 연결합니까?
<asp:SqlDataSource ID="emailresult" runat="server"
ConnectionString='<%$ ConnectionStrings:databaseconnection %>'
SelectCommand ="SELECT [ID], [email], [role] FROM [emailtest]">
</asp:SqlDataSource>
protected void EmailTestButton_Click(object sender, EventArgs e)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add("");
mailMessage.To.Add("");
mailMessage.From = new MailAddress("[email protected]");
mailMessage.Subject = "Scrum Management Studio - Role Confirmation";
mailMessage.IsBodyHtml = true;
mailMessage.Body = "Hello, <br /><br /> You have been assigned the role of <b>[ROLE]</b> <br /><br /> \n\nKind Regards, <br />The Scrum Management Studio Team" ;
mailMessage.Priority = MailPriority.High;
SmtpClient smtpClient = new SmtpClient("smtp-isp.com");
smtpClient.Send(mailMessage);
Response.Write("Email has been successfully sent");
}
catch (Exception ex)
{
Response.Write("Could not send the email - error: " + ex.Message);
}
}
거기에서 생각 생각 : 데이터베이스에서 문자열 (이메일)을 반환하는 메서드를 작성하고 (stringreturned) 새 MailAddress에서 사용할 수 있습니다; –
정확히 여기에 갇혀 있습니까? 전자 메일 주소 읽기 -> MailAddress에서 설정 -> 전자 메일 보내기 – Liam
도움이되지 않습니다! – SHarvey43