그래서 백엔드를 정리하고 이메일을 정리하려고합니다. html 파일을 여기에 직접 넣는 대신에 html 파일에 include하는 방법이 있습니까? 아니면 더 좋은 방법일까요? 당신이 ASP.Net MVC를 사용하는 경우.cs C# .net에 HTML 페이지를 포함하십시오.
public void SendWelcomeEmail(int uid)
{
SqlCommand command = EmailCommandList.GetRegisteredEmail;
BciDatabase db = new BciDatabase("db");
command.Parameters["@User_Id"].Value = uid;
using (SqlDataReader dr = db.ExecuteReader(command))
{
Member member = new Member();
if (dr != null && !dr.IsClosed && dr.Read())
{
while (dr.Read())
{
string emailAddress = (string)dr["Email"];
MailMessage mail = new MailMessage();
mail.Subject = "Welcome to the site";
mail.Body = "<html><head></head><body><p>Hello, welcome to the site!</body></html>";
mail.IsBodyHtml = true;
mail.From = new MailAddress("[email protected]");
mail.To.Add(new MailAddress(emailAddress));
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("myemail", "mypass"),
EnableSsl = true
};
client.Send(mail);
}
}
}
}
외부 파일의 내용을 문자열 변수로 읽고 'mail.Body = fileContents;'를 설정할 수 있습니다. –
어떻게해야합니까? Im new – tytyguy