0
메시지를 볼 수 있도록 메일을 보내려고합니다.이 경우 컴퓨터의 지정된 폴더로 그리드보기를 보내려고합니다. 따라서 메일을 보내고 있지만 폴더에서 끝나지 않습니다. 어떻게해야합니까? 네트워크를 통해 메일을 폴더로 보내기
나는 Web.config를이 추가 :<system.net>
<mailSettings >
<smtp deliveryMethod="Network" from="[email protected]">
<network host="staging.itmaniax.co.za"/>
<specifiedPickupDirectory pickupDirectoryLocation="C:\testdump\emaildump\"/>
</smtp>
</mailSettings>
이가있는 gridview를 보내는 내 코드입니다. (나는 포트에 연결하지 않는 한 나는려면 SmtpClient를 필요로하지 않는 가정, 중 25 또는 587) :
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\smtp" />
이 님의 Web.config에서
private void MailReport()
{
//*****************************************************
string to = "[email protected]";
string From = "[email protected]";
string subject = "Report";
string Body = "Good morning, Please view attachment<br> Plz Check d Attachment <br><br>";
Body += GridViewToHtml(GridView1);
Body += "<br><br>Regards,<br>Arian Geryts(ITManiax)";
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(" <html><body><br></body></html> <br><br><br> " + body);
//*****
/*client = new SmtpClient("smtp.gmail.com", 25);
client.Host = "staging.itmaniax.co.za";
client.Port = 25;
//****
client.EnableSsl = true;
client.Send(msg);*/
k = true;
}