Using an web page a a template for email on data submit.

G

Guest

I am trying to figure out if this is possible and how as I have burnt my
brain out today.

I have an application that submits data to a SQL database and an email is
generated for notifications on a portion of that data. I would like to create
a web page that I can reference as a variable sorta like this

using namespace.templates;

Notification notEmail = new Notification();

the based on however I need to submit my data be able to take notEmail and
translate to the HTMl and submit to the notification table this html in a
text field.

Then later my email process can process the text into and HTML email and
send it to the proper parties.

My issue is how to get the html by using the page template from and ASP.NET
project on submit.

Hope that makes sense.

Thanks in advance.
 
S

souri challa

If I understand you correctly, you're looking to create HTML page
template interspersed with data to be sent in email.Here is an approach
I have used.
1)Design an aspx page for your template with all the HTML you need and
Label/Literal controls for the data.This aspx page should implement
code to fill in the controls with the values posted to it.
2)Now when you need to send the email, use System.Net.HTTPWebRequest to
retrieve the ASPX page content after posting the required data to that
form.
3)Send the content in email.

HTH
 
G

Guest

Sorry I am a bit fried from serveral other things today and just am not
seeing it. Can you post an example of the code calling the page please.

Thansk very much in adavance.
 
S

souri challa

Here is some code. Hope this enough to get you started.

/// <summary>
/// Used to screen scrape a web page and get the HTML output.
/// This approach is employed to create rich HTML text used for the
notification templates.
/// </summary>
public string GetWebPageHTMLString(string url,NameValueCollection
nameValueCollection)
{
System.Net.WebClient wc = new WebClient();
wc.Credentials = CredentialCache.DefaultCredentials;

Byte[] htmlString = wc.UploadValues(url,"POST",nameValueCollection);
System.Text.UTF8Encoding oUTF8 = new System.Text.UTF8Encoding();
return oUTF8.GetString( htmlString);


}

You may call this like.
NameValueCollection _postData = new NameValueCollection();
_postData.Add("variable1",value1)
_postData.Add("variable2",value2);
string html=
GetWebPageHTMLString(url,_postData);

//Now email this HTML
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top