Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Constructing an invoice the body of an email

Hi

In my ASP.net web app I want to send an invoice embedded in the body of an email. At the moment I am sending certain
emails using the code  below. That works well for formatted text. Constructing an invoice that has everything
in the right place is a bit more tricky. I am looking for a few pointers on how to achieve this. Thanks

            Dim oHBody As String = ""
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor1 & " name = 'Calibri'>" & oIntro & "</font></body></html>"
            oHBody = oHBody & "<br>"
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor2 & " name = 'Calibri'>" & sDate & "</font></body></html>"
            oHBody = oHBody & "<br>"

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

if you going to generate an exact invoice, I would suggest you generate the pdf and attach it into your email instead.
Avatar of Murray Brown

ASKER

HTML in the email body should be fine too.

but what I would usually do is to create a separate HTML template ( so that when it's being opened, I know how it looks like ) for the ease of troubleshooting, and not really will write the HTML codes in C#.

when I want to use that use that HTML template, I just use the .net IO library to load it as string for the integration.
Hi Ryan. I already created a separate web page as the document shown below. Could this be used in the way that you mentioned?

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Purchase Order.aspx.vb" Inherits="Steel.Purchase_Order" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            height: 23px;
        }
        .auto-style2 {
            height: 22px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
                     <asp:Panel ID="Panel1" runat="server">

                <table>
                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblBuyerCompanyName" runat="server" Font-Size="X-Large"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                         <td>
                             <asp:Label ID="lblSpacer" runat="server" Width="100px"></asp:Label>
                        </td>
                        <td class="auto-style2">
                            <asp:Label ID="Label21" runat="server" Font-Bold="True" Text="PURCHASE ORDER" Font-Size="X-Large"></asp:Label>
                        </td>
                   
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                    </tr>
                       <tr>
                        <td class="auto-style2">
                            <asp:Image ID="Image1" runat="server" Height="110px" Width="209px" />
                           </td>
                        <td class="auto-style2">
                            &nbsp;</td>
                                <td></td>
                        <td class="auto-style2">
                            &nbsp;</td>
                        <td class="auto-style2">
                            </td>
                        <td class="auto-style2">
                            &nbsp;</td>
                        <td class="auto-style2"></td>
                    </tr>
                       <tr>
                        <td>
                            <asp:Label ID="lblBuyerAddress1" runat="server"></asp:Label>
                           </td>
                        <td></td>
                        <td>
                            <asp:Label ID="Label16" runat="server" Text="Company Reg No: "></asp:Label>
                           </td>
                        <td>
                            <asp:Label ID="lblCompanyReg" runat="server"></asp:Label>
                           </td>
                        <td></td>
                        <td>
                            <asp:Label ID="Label22" runat="server" Text="Date"></asp:Label>
                           </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblBuyerAddress2" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                             <td class="auto-style2">
                                 <asp:Label ID="Label17" runat="server" Text="Vat No:"></asp:Label>
                        </td>
                        <td class="auto-style2">
                            <asp:Label ID="lblVATNumber" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2">
                            <asp:Label ID="lblDate" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                    </tr>
                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblBuyerAddress3" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td>
                            <asp:Label ID="Label18" runat="server" Text="Tel No:"></asp:Label>
                        </td>
                        <td class="auto-style2">
                            <asp:Label ID="lblTelephoneNumber" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2">
                            <asp:Label ID="Label24" runat="server" Text="Document No"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                    </tr>

                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblBuyerAddress4" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td>
                            <asp:Label ID="Label19" runat="server" Text="Email: "></asp:Label>
                        </td>
                        <td class="auto-style2">
                            <asp:Label ID="lblEmail" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2">
                            <asp:TextBox ID="txtDocumentNo" runat="server" Width="111px"></asp:TextBox>
                        </td>
                        <td class="auto-style2">&nbsp;</td>
                    </tr>
                              <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblBuyerAddress5" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2">
                            &nbsp;</td>
                        <td></td>
                        <td class="auto-style2">
                            &nbsp;</td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2">
                            &nbsp;</td>
                        <td class="auto-style2"></td>
                    </tr>


                       <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                                <td>&nbsp;</td>
                        <td>
                            &nbsp;</td>
                        <td></td>
                        <td>
                            &nbsp;</td>
                        <td></td>
                    </tr>
 
           
            
                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="Label32" runat="server" Text="To: "></asp:Label>
                            &nbsp;<asp:Label ID="lblSellerName" runat="server"></asp:Label>
                            </td>
                        <td class="auto-style2">
                            &nbsp;</td>
                            <td></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                    </tr>
                    <tr>
                        <td class="auto-style2">
                            <asp:Label ID="Label31" runat="server" Text="Attention: "></asp:Label>
                            <asp:Label ID="lblAttention" runat="server"></asp:Label>
                        </td>
                        <td class="auto-style2">&nbsp;</td>
                             <td></td>
                        <td class="auto-style2">
                            <asp:Label ID="lblDeliverToHeader" runat="server">Deliver To:</asp:Label>
                        </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                    </tr>

                       <tr>
                        <td class="auto-style1">
                            <asp:Label ID="lblSellerAddress1" runat="server"></asp:Label>
                           </td>
                        <td class="auto-style1"></td>
                                <td></td>
                        <td class="auto-style1">
                            <asp:TextBox ID="txtShipAddress1" runat="server" Width="200px"></asp:TextBox>
                           </td>
                        <td class="auto-style1"></td>
                        <td class="auto-style1"></td>
                        <td class="auto-style1"></td>
                    </tr>
                       <tr>
                        <td class="auto-style2">
                            <asp:Label ID="lblSellerAddress2" runat="server"></asp:Label>
                           </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2">
                            &nbsp;</td>
                                <td>
                                    <asp:TextBox ID="txtShipAddress2" runat="server" Width="200px"></asp:TextBox>
                           </td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                        <td class="auto-style2"></td>
                    </tr>
                       <tr>
                        <td>
                            <asp:Label ID="lblSellerAddress3" runat="server"></asp:Label>
                           </td>
                        <td></td>
                                <td></td>
                        <td>
                            <asp:TextBox ID="txtShipAddress3" runat="server" Width="200px"></asp:TextBox>
                           </td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblSellerAddress4" runat="server"></asp:Label>
                        </td>
                        <td></td>
                        <td></td>
                        <td>
                            <asp:TextBox ID="txtShipAddress4" runat="server" Width="200px"></asp:TextBox>
                        </td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblSellerAddress5" runat="server"></asp:Label>
                        </td>
                        <td></td>
                        <td></td>
                        <td>
                            <asp:TextBox ID="txtShipAddress5" runat="server" Width="200px"></asp:TextBox>
                        </td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
              

                </table>
   

            </asp:Panel>

            <asp:Panel ID="Panel2" runat="server" Height="228px">
                <asp:GridView ID="GridView1" runat="server" ShowFooter="True" BorderStyle="None" GridLines="None">
                    <HeaderStyle Height="50px" HorizontalAlign="Left" />
                </asp:GridView>
                <asp:TextBox ID="txtDescription" runat="server" Width="613px"></asp:TextBox>
                <br />
                <asp:Label ID="Label14" runat="server" Text="Total" Visible="False"></asp:Label>
                &nbsp;
                <asp:Label ID="lblTotal" runat="server" Text="-" Visible="False"></asp:Label>
                <br />
                <br />
                &nbsp;</asp:Panel>
            <asp:Panel ID="Panel3" runat="server">
                <asp:Button ID="printButton" runat="server" Text="Print Page" OnClientClick="javascript:window.print();" Width="128px" />
                <asp:Button ID="btnHideBoxes" runat="server" Text="Hide Boxes" Width="134px" />
                <asp:Button ID="btnViewBoxes" runat="server" Text="View Boxes" Width="125px" />
                <asp:Button ID="btnEmailTo" runat="server" Text="Email To" Width="131px" />
                <asp:TextBox ID="txtEmailTo" runat="server" Width="159px"></asp:TextBox>
            </asp:Panel>
        </div>
    </form>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much for the advice