mail for ASP.NET email smtp mail for ASP.NET email smtp
mail for ASP.NET email smtp

Other Products
mail for ASP.NET email smtp
  "Unbelievable response time. Thanks Dave!"
Micky McQuade
EstateSales.NET
 
   More Testimonies

Email a DataGrid or a Usercontrol


Back to index.


The following example demonstrates how to leverage your existing code and email a datagrid or usercontrol with minor changes. For example, take this fictitious order display below (which is a usercontrol). Something like this might be seen on a typical checkout page. With a few lines of code, you can email this usercontrol to your customers.

To test, enter your mail information and click send.
Mail Server: (ex: mail.mycompany.com)
From Email Address: (ex: from@mycompany.com)
TO Email Address: (ex: to@yourcompany.com)
 

The box is not shipped.
aspNetEmail is a    
downloadable product.
 
aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Runner Up ASP.NET Email Control
Voted Runner Up Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetTraceRoute
Voted Runner Up Networking Control
Runner Up - Networking Control

 


Order 400330
Ship To/Shipping Method Bill To/Credit Card
Steve James
Customer Street
Customer City,OH 45040
someone@hotmail.com
 
Standard Mail
 
Steve James
Customer Street
Customer City,OH 45040
someone@hotmail.com
 
Payroll
 
Order Summary
Item # Description Qty Each Total
SKU_0001 long sleeved plaid shirts
Size: Small
Color: Light Blue
1 $11.25 $11.25
SKU_0014 solid rugby shirts
Size: Medium
Color: White
1 $10.50 $10.50
SKU_0003 tn bridge
License: For Workstation Single
Method: Physical Delivery
1 $189.00 $189.00
         
      SubTotal: $210.75
      SalesTax(6.5%): $13.70
      Shipping: $14.95
      Total: $239.40

This sample, and many others can be downloaded at Examples.aspx.

The code to acomplish this is as easy as


[C#]

//create the email
EmailMessage msg = new EmailMessage( "mail.mycompany.com" );
msg.To= txtEmail.Value;
msg.FromAddress = "orders@mycompany.com";
msg.Subject = "Add a Usercontrol to an email.";
msg.Body = "This sample contains a usercontrol that was appended to the body of this email.";

//add the control
uc_Order uc = (uc_Order)Page.LoadControl("uc/uc_Order.ascx");
uc.RenderMe();
msg.AppendControlToBody( uc );

//send the email
msg.Send();




[Visual Basic]
'create the email
Dim msg As EmailMessage =  New EmailMessage("mail.mycompany.com") 
msg.To= txtEmail.Value
msg.FromAddress = "orders@mycompany.com"
msg.Subject = "Add a Usercontrol to an email."
msg.Body = "This sample contains a usercontrol that was appended to the body of this email."
 
'add the control
Dim uc As uc_Order = CType(Page.LoadControl("uc/uc_Order.ascx"), uc_Order)
uc.RenderMe()
msg.AppendControlToBody(uc)
 
'send the email
msg.Send()