aspxページをhtmlに変換し、hvでvarmyPageHTMLに保存しました。これが使用しているコードです...しかし、私はhtml部分を添付ファイルまたはメールの本文として電子メールとして送信したいと思います。助けてください。
//this method on providing the url of the webpage copies the image of that webpage.
protected void Button1_Click(object sender, System.EventArgs e)
{
{
WebClient myClient = new WebClient();
string myPageHTML = null;
byte[] requestHTML;
// Gets the url of the page
string currentPageUrl = Request.Url.ToString();
UTF8Encoding utf8 = new UTF8Encoding();
// by setting currentPageUrl to www.yahoo.com it will fetch the source (html)
// of the yahoo.com and put it in the myPageHTML variable.
// currentPageUrl = "http://www.yahoo.com";
requestHTML = myClient.DownloadData("http://localhost:31788");
myPageHTML = utf8.GetString(requestHTML);
Response.Write();
try
{
SendMail();
}
catch (Exception) { }
}
protected void SendMail()
{
var userName = " from email";
var toAddress = YourEmail.Text.ToString();
const string Password = "password";
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "10.238.52.880";
smtp.Port = 25;
smtp.EnableSsl = false;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(userName, Password);
smtp.Timeout = 20000;
}
smtp.Send(userName, toAddress, subject, body);
}
}