I want to send Email and it's Content should be a well Designed aspx Page. But the aspx page should not be sent as a Hyper-Link it should be shown as message Content?
Can It is Possible if ay suggession Please Reply开发者_开发百科...
Mohammed
you can get the html of the page into a string with a web request like this:
WebRequest request;
string text;
string url = "UrlToGet";
request = (HttpWebRequest)
WebRequest.Create(url);
using (WebResponse response = request.GetResponse())
{
using (StreamReader reader =
new StreamReader(response.GetResponseStream()))
{
text = reader.ReadToEnd();
}
}
An aspx page is interpreted by the server and rendered to Java-script and html. Who will be doing this in that case? This is (currently) not possible.
The only thing you can do is got to html and write your message in html - so you have the looks but not the functionality.
hth
Mario
you can do like this.....
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
string url = "http://www.microsoft.com";
mail.Body = HttpContent( url );
mail.BodyFormat = MailFormat.Html;
mail.UrlContentBase = url;
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );
}
//screen scrape a page here
private string HttpContent( string url )
{
WebRequest objRequest= System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader( objRequest.GetResponse().GetResponseStream() );
string result = sr.ReadToEnd();
sr.Close();
return result;
}
精彩评论