기본 이메일을 폴더로 보내려고합니다. 전자 메일을 받았지만 본문이 완전히 누락되었습니다. 기본 이메일을 폴더로 보내려고합니다
private void MailReport()
{
string to = "[email protected]";
string From = "[email protected]";
string subject = "Report";
**string Body = "Dear sir ,<br> Plz Check d Attachment <br><br>";**
bool send = sendMail(to, From, subject, Body);
if (send == true)
{
string CloseWindow = "alert('Mail Sent Successfully!');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
else
{
string CloseWindow = "alert('Problem in Sending mail...try later!');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
}
public bool sendMail(string to, string from, string subject, string body)
{
bool k = false;
try
{
MailMessage msg = new MailMessage(from, to);
msg.Subject = subject;
AlternateView view;
SmtpClient client;
StringBuilder msgText = new StringBuilder();
view = AlternateView.CreateAlternateViewFromString(msgText.ToString(), null, "text/html");
msg.AlternateViews.Add(view);
msgText.Append("<body><br></body></html> <br><br><br> " + body);
client = new SmtpClient();
client.Host = "staging.itmaniax.co.za";
client.Send(msg);
k = true;
}
catch (Exception exe)
{
Console.WriteLine(exe.ToString());
}
return k;
}
<system.net>
<mailSettings >
<smtp deliveryMethod="specifiedPickupDirectory" from="[email protected]">
<network host="staging.itmaniax.co.za"/>
<specifiedPickupDirectory pickupDirectoryLocation="C:\testdump\emaildump\"/>
</smtp>
</mailSettings>
나는 그것이 비주얼 스튜디오 2008과 수행으로 문제를 느끼는 것은 몸과 HTML로 자리 잡고 있습니다. 조언이 있으십니까?
'sendMail' 메소드에 도달 할 때 중단 점을 넣고'body'에 값이 있는지 확인하십시오. 'msgText'의 HTML은 완전히 잘못되었습니다. 나는 HTML을 없애고, 그냥 몸에 덤프하고 OK를 통해 볼 수 있는지 확인합니다. – Arran