Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
antares686 - 22 Jul 2005 21:31 GMT
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.
souri challa - 22 Jul 2005 22:45 GMT
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
antares686 - 22 Jul 2005 23:09 GMT
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.

> 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
[quoted text clipped - 8 lines]
>
> HTH
souri challa - 22 Jul 2005 23:39 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.