Since you can save both sections into database, I think you must have looped this, right ?
You could try to use the same data for your email.
Or please show me your code, so that I can help you more efficient.
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I apologize for the late response. I had an emergency yesterday that literally kept me up all night.
About your solution, I am actually pulling the data from the database.
The issue is the way the data is used in the tables that is wrapped with body as shown on the code below.
I grabbed the code from preview page using VIEW SOURCE.
I am not sure of a better way of using the actual asp.net markup from preview page:
protected void btnSendEmail_Click()
{
FillSummary();
//Read in connection String
// SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
SqlConnection Conn = new SqlConnection(connStr);
string sendEmailTo = String.Empty;
//Open connection to the database
Conn.Open();
//Open command object
s = "SELECT t.[PID],t.[TaxPayerFullName],t.[Address],t.[City]";
s+= ",t.[State],t.[Zip],a.[EquipmentTypeID],a.[TaxYear],a.[AirCraftRegNo],a.[TaxPyrRetdVal],api.[DateSold]";
s+= ",api.[SalePrice],api.[Description],api.[BuyerFullName],api.[BuyerAddress]";
s+= ",api.[BuyerCity],api.[BuyerState],api.[BuyerZipCode],api.[PreviousOwnerName],api.[PreviousOwnerAddress],api.[PreviousOwnerCity],api.[PreviousOwnerState]";
s+= ",api.[PreviousOwnerZipCode],api.[sTitle],api.[signDate],ase.[PurchaseType],ase.[Registration_No],ase.[City],ase.[County]";
s+= ",ase.[State],ase.[MFG_Make],ase.[MFG_Model],ase.[Year_Built],ase.[SerialNumber],ase.[DatePurchased],ase.[Aircraft_Cost]";
s+= ",ase.[Hours_BTW_Overall],ase.[Hours_Last_Since],ase.[Last_Hour_Overhauled],ase.[Total_HoursOnAirframe]";
s += ",ase.[Avionics_Extra_Equip],ase.[FileDate],ase.[aircraftissues],ase.[IssueDetails],d.CityName, api.preparerName, api.emailAddr ";
s+= "FROM TaxPayer t ";
s+= "INNER JOIN AircraftInfo a ON t.PID = a.PID ";
s+= "INNER JOIN dbo.AircraftPurchaserInfo api ON a.PID=api.PID ";
s+= "INNER JOIN dbo.AircraftScheduleE ase ON a.PID=ase.PID ";
s += "INNER JOIN DeKalbCity d on d.Seq = api.cityID ";
s += "WHERE a.PID =@pin";
SqlCommand scmd = new SqlCommand(s, Conn);
scmd.CommandType = CommandType.Text;
scmd.Parameters.AddWithValue("@pin", accountnumber.Text);
// bool validEmail = false;
//*** The Fastest way to get Single Row Data ***
SqlDataReader dr = scmd.ExecuteReader();
while (dr.Read())
{
pin = dr.GetInt32(0);
tpfullname = dr.GetString(1);
regaddr = dr.GetString(2);
regcity = dr.GetString(3);
regstate = dr.GetString(4);
regzip = dr.GetString(5);
etypeid = dr.GetInt32(6);
taxYr = dr.GetInt32(7);
aRegNo = dr.GetString(8);
taxPyrRetdVal = dr.GetDecimal(9);
dteSold = dr.GetDateTime(10);
sPrice = dr.GetDecimal(11);
descr = dr.GetString(12);
buyerfullName = dr.GetString(13);
buyerAddr = dr.GetString(14);
buyerCity = dr.GetString(15);
buyerState = dr.GetString(16);
buyerZip = dr.GetString(17);
previousOwnerName = dr.GetString(18);
previousOwnerAddr = dr.GetString(19);
previousOwnerCity = dr.GetString(20);
previousOwnerState = dr.GetString(21);
previousOwnerZip = dr.GetString(22);
sTitle = dr.GetString(23);
signDte = dr.GetDateTime(24);
purchaseType = dr.GetString(25);
registrationNo = dr.GetString(26);
city = dr.GetString(27);
County = dr.GetString(28);
state = dr.GetString(29);
mfgMake = dr.GetString(30);
mfgModel = dr.GetString(31);
yearBuilt = dr.GetInt32(32);
SerialNumber = dr.GetString(33);
dtePurchased = dr.GetDateTime(34);
AircraftCost = dr.GetDecimal(35);
HrsBTWOverall = dr.GetString(36);
HrsLastSince = dr.GetString(37);
LastHrOverhauled = dr.GetString(38);
totalHrsOnAirframe = dr.GetString(39);
AvionicsExtraEquip = dr.GetString(40);
fileDate = dr.GetDateTime(41);
aircraftIssues = dr.GetString(42);
issueDetails = dr.GetString(43);
dCityName = dr.GetString(44);
preparername = dr.GetString(45);
email = dr.GetString(46);
}
//if we are here then something got returned.
//so probably a valid email.
// validEmail = true;
////Ready email message to recepient
string body = "<br />";
body = body + " <table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td style='width:30%;vertical-align: text-top;font-weight:normal;text-align:center;color:gainsboro'>FOR OFFICE ONLY</td>";
body = body + " <td style='width:70%;'><div class='auto-style7'><span style='font-weight:bold;color:#4b4b4b;'>AIRCRAFT PERSONAL PROPERTY TAX RETURN</span><br />";
body = body + " <span style='color:#4b4b4b;'>This Return will be considered Public Information and Open for Public Inspection<br />";
body = body + " Return completed form to address listed below.</span></div></td>";
body = body + "</tr>";
body = body + "<tr>";
body = body + " <td style='vertical-align: text-top;width:45%;'>";
body = body + " <table border='1' class='nav-justified'>";
body = body + " <tr>";
body = body + " <td class='auto-style5'>TAX YEAR</td>";
body = body + " <td rowspan='2' class='auto-style2'><span style='margin-left:7px;color:#000;'>IF ASSISTANCE NEEDED CALL</span><br /> <span style='margin-left:32px;color:#000;'>770-896-2463</span></td>";
body = body + " <td class='auto-style1'>ACCOUNT NUMBER</td>";
body = body + "</tr>";
body = body + "<tr>";
body = body + " <td class='auto-style5'><span id='lblTaxYr' style='color: #0093B2;font-weight:bold;'>" + lblTaxYr.Text + "</span></td>";
body = body + " <td class='auto-style1'><div class='input text'> <span id='lblAcctNo' disabled='disabled' style='width:155px; color: #0093B2;font-weight:bold;'>" + lblAcctNo.Text + "</span></div></td>";
body = body + "</tr>";
body = body + " <tr>";
body = body + " <td class='auto-style5'><span style='color:red;'>DUE DATE</span></td>";
body = body + " <td colspan='2' >OWNER'S PHONE NUMBER (LIST)</td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td class='auto-style5'><span id='lblDueDate' style='color: #0093B2;font-weight:bold;'>" + lblDueDate.Text + "</span></td>";
body = body + " <td colspan='2' ><span id='lblOwnerPhone' style='color: #0093B2;font-weight:bold;'>" + lblOwnerPhone.Text + "</span></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table style='width:60%'>";
body = body + " <tr>";
body = body + " <td style='text-align:center'><br />Taxpayer NAME AND ADDRESS</td>";
body = body + " </tr>";
body = body + " <tr><td style='border-collapse: collapse;border: 0px solid black;'> </td></tr>";
body = body + " <tr>";
body = body + " <td>";
body = body + " <table border='0'>";
body = body + " <tr>";
body = body + " <td>NAME:</td><td><div class='input text'> <span id='lblfName' style='width:459px;color: #0093B2;font-weight:bold;'>" + lblfName.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>ADDRESS:</td><td><div class='input text'> <span id='lblfAddress' style='width:459px;color: #0093B2;font-weight:bold;'>" + lblfAddress.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='0'>";
body = body + " <tr>";
body = body + " <td><span style='margin-left:2px;color:#000;'>CITY:</span> </td><td><div class='input text'> <span id='lblfCity' style='width:150px; color: #0093B2;font-weight:bold;'>" + lblfCity.Text + "</span></div></td><td> STATE:</td><td><div class='input select'>";
body = body + " <span id='lblfStates' class='Label' disabled='disabled'>" + lblfStates.Text + "</span> ";
body = body + " </div></td><td> ZIP:</td><td><div class='input text'> <span id='lblfZip' style='width:57px; color: #0093B2;font-weight:bold;'>" + lblfZip.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr><td style='border-collapse: collapse;border: 0px solid black;'> </td></tr><tr><td style='border-collapse: collapse;border: 0px solid black;'> </td></tr>";
body = body + " <tr>";
body = body + " <td style='border-collapse: collapse;border-top: 1px solid black;border-bottom: 1px solid black;width:100%;'><span style='color:red'>The last day for filing this application to receive full exemption<br />";
body = body + " is listed in the DUE DATE column above.</span> Note: Most counties do not accept metered mail dates as filing date unless counter<br />";
body = body + " stamped by the post office. Be sure that the date of deposit and the postmark date are the same if mailing is close to the deadline.<br /></td>";
body = body + " </tr>";
body = body + " </table> ";
body = body + " </td>";
body = body + " <td style='vertical-align: text-top;width:55%;'>";
body = body + " <table border='0' style='width:100%'>";
body = body + " <tr>";
body = body + " <td style='border-collapse: collapse;border-bottom: 1px solid black;'><div class='auto-style7'>NAME AND RETURN ADDRESS</div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='border-collapse: collapse;border-bottom: 1px solid black;'><div class='auto-style7'>TAX ASSESSORS<br />";
body = body + " PROPERTY APPRAISAL & ASSESSMENT ADMIN.<br />";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='border-collapse: collapse;border: 1px solid black;'>TAX SITUS (WHERE YOU LIVE):</td>";
body = body + " </tr>";
body = body + " <tr><td> </td></tr>";
body = body + " <tr>";
body = body + " <td>";
body = body + " <span id='lblsitus' disabled='disabled' style='width:90%;height:70px;width:257px;color: #0093B2;font-weight:bold;'>" + lblsitus.Text + "</span>";
body = body + " <div id='divcitylistprev' style='margin-top:-45px;margin-left:110px;'><span id='lblcitylist' class='form-control' style='width:400px; color: #0093B2;font-weight:bold;'>" + dCityName + "</span></div>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='border-collapse: collapse;border: 1px solid black;'><div class='auto-style7'><span style='color: #0093B2;font-weight:bold;'><input id='chksameAddr' type='checkbox' name='chksameAddr' />" + chksameAddr.Text + "</span>CHECK BOX IF MAILING ADDRESS OR NAME IS SAME<br /> ";
body = body + " OTHERWISE, PLEASE CORRECT IN SPACE PROVIDED BELOW</div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='0'>";
body = body + " <tr>";
body = body + " <td>NAME:</td><td style='border-collapse: collapse;border: 1px solid black;'><div class='input text'> <span id='lblfullName' style=' color: #0093B2;font-weight:bold;width:600px;'>" + lblfullName.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>ADDRESS:</td><td style='border-collapse: collapse;border: 1px solid black;'><div class='input text'> <span id='lblAddress' style='width:600px; color: #0093B2;font-weight:bold;'>" + lblfAddress.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='0'>";
body = body + " <tr>";
body = body + " <td>CITY:<span style='margin-left:32px;color:#000;'></span></td><td style='border-collapse: collapse;border: 1px solid black;'><div class='input text'> <span id='lblCity' style='color: #0093B2;font-weight:bold;width:100px;'>" + lblfCity.Text + "</span></div></td><td><span style='margin-left:7px;color:#000;'>STATE:</span></td><td style='border-collapse: collapse;border: 1px solid black;'><div class='input select'>";
body = body + " <span id='lblStates' class='Label' disabled='disabled' style='width:150px;'>" + lblStates.Text + "</span> ";
body = body + " </div></td><td><span style='margin-left:30px;color:#000;'>ZIP:</span></td><td style='border-collapse: collapse;border: 1px solid black;'><div class='input text'> <span id='lblZip' style='color: #0093B2;font-weight:bold;width:100px;'>" + lblfZip.Text + "</span></div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='1' style='width:100%;text-align:center;'>";
body = body + " <tr>";
body = body + " <td style='width:100%;vertical-align: text-top;'>";
body = body + " <table cellspacing='0' rules='all' border='1' width='100%' style='border-collapse:collapse;table-layout: fixed;'>";
body = body + " <tr>";
body = body + " <th align='left' scope='col'>Aircraft Registration #:</th>";
body = body + " <th scope='col'>Taxpayer Returned Value <br />As of Jan This Year</th>";
body = body + " <th scope='col'><span style='color:gainsboro;margin-left:50px;'>For Tax Office use Only</span> <br /><span style='color:gainsboro;margin-left:50px;'> (Tax Assessirs Value)</span></th>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>";
body = body + " <span class='form-control' style='width: 493px; color: #0093B2;font-weight: bold;'> " + aRegNo + "</span>";
body = body + " </td>";
body = body + " <td align='left'>";
body = body + " <span class='form-control txtPayerret' style='width: 326px;color: #0093B2; font-weight: bold;'>" + taxPyrRetdVal + "</span>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='1' style='width:90%;text-align:center'>";
body = body + " <tr>";
body = body + " <td width='24.2%'>TOTAL<span style='margin-left:300px;color:#000000;font-weight:bold;'>></span></td>";
body = body + " <td style='width:23%'>";
body = body + " <span id='lblTotalPrev' style='color: #0093B2;font-weight: bold;'>" + lblTotalPrev.Text + "</span></td>";
body = body + " <td style='width:62.8%'></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table style='width:100%;border: 1px solid black;'>";
body = body + " <tr>";
body = body + " <td style='width:33.3%;border-collapse: collapse;white-space:nowrap;'>";
body = body + " Airport where aircraft primary home based city: <span id='lblAircraftCity' style='width:270px;color: #0093B2;font-weight:bold;'>" + city + "</span></td>";
body = body + " <td style='text-align:center;'>";
body = body + " </td>";
body = body + " <td style='width:33.3%;border-collapse: collapse;white-space:nowrap;'>";
body = body + " County: <span id='lblAircraftcnty' style='width:270px;color: #0093B2;font-weight:bold;'>" + County + "</span></td>";
body = body + " <td style='text-align:center;'>";
body = body + " </td>";
body = body + " <td style='width:33.3%;border-collapse: collapse;white-space:nowrap;'>";
body = body + " State: <span id='lAblircraftstate' style='color: #0093B2;font-weight:bold;'>" + state + "</span> </td>";
body = body + " <td style='text-align:center;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table style='width: 100%; border: 1px solid black;'>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Registration 'N' #:<span id='lblARegNo' style='width: 270px; margin-left: 195px;color: #0093B2;font-weight:bold;'>" + aRegNo + "</span>";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " AVIONICS AND EXTRA EQUIPMENT";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " MFG. Name: (make):<span id='lblAMake' style='width: 270px; margin-left: 175px;color: #0093B2;font-weight:bold;'>" + mfgMake + "</span>";
body = body + " </td>";
body = body + " <td style='width: 50%; text-align: center; border: 1px solid black;' rowspan='10'>";
body = body + " <span id='lblavionics' TextMode='MultiLine' class='form-control' style='width: 100%;";
body = body + " height: 700px;color: #0093B2;font-weight:bold;'>" + AvionicsExtraEquip + "</span>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Model Name OR #::<span id='lblAModelNo' style='width: 270px; margin-left: 184px;color: #0093B2;font-weight:bold;'>" + mfgModel + "</span>";
body = body + " </td>";
body = body + " <td style='width: 50%; text-align: center; border: 0px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Year Built:<span id='lblAYRBuilt' style='width: 270px; margin-left: 252px;color: #0093B2;font-weight:bold;'>" + yearBuilt + "</span>";
body = body + " </td>";
body = body + " <td style='width: 50%; text-align: center; border: 0px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Serial Number:<span id='lblASN' style='width: 270px; margin-left: 219px;color: #0093B2;font-weight:bold;'>" + SerialNumber + "</span>";
body = body + " </td>";
body = body + " <td style='width: 50%; text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Date Purchased:<span id='lblDatePurchased' style='width: 270px; margin-left: 205px;color: #0093B2;font-weight:bold;'>" + dtePurchased + "</span>";
body = body + " </td>";
body = body + " <td style='width: 50%; text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black;'>";
body = body + " Purchased:<span id='lblPurchType' style='color: #0093B2;font-weight:bold;'>" + purchaseType + "</span>";
body = body + " <br />";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Cost:<span id='lblAircraftCost' style='width: 270px; margin-left: 287px;color: #0093B2;font-weight:bold;'>" + AircraftCost + "</span>";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Hours Between Overhauls(TBO):<span id='lblHrsBtwnTBO' style='width: 270px; margin-left: 90px;color: #0093B2;font-weight:bold;'>" + HrsBTWOverall + "</span>";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Hours Since Last OVerhaul:<span id='lblHrsOverhaul' style='width: 270px; margin-left: 127px;color: #0093B2;font-weight:bold;'>" + HrsLastSince + "</span>";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Last Overhaul:<span id='lblOverhaul' style='color: #0093B2;font-weight:bold;'>" + LastHrOverhauled + "</span>";
body = body + " <br />";
body = body + " </td>";
body = body + " <td style='text-align: center; border: 1px solid black;'>";
body = body + " </td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='width: 50%; border-collapse: collapse; border: 1px solid black; white-space: nowrap;'>";
body = body + " Total Hours On Airframe As of Jan. 1:<span id='lblTotOnAirFrm' style='width: 270px;";
body = body + " margin-left: 58px;'>" + totalHrsOnAirframe + "</span>";
body = body + " </td>";
body = body + " <td style='border: 1px solid black;'>";
body = body + " NOTE: Please submit a copy of your log book to substantiate T.B.O. and<br />";
body = body + " airframe hours.";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table border='0' width='90%'>";
body = body + " <tr> ";
body = body + " <td colspan='2'>";
body = body + " <span style='text-align:left;'> If purchased used this year, write the name and address of the";
body = body + " previous owner.</span></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>NAME: </td><td><div class='input text'> <span id='lblFNamePrev' style='width:450px;color: #0093B2;font-weight:bold;'>" + previousOwnerName + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>ADDRESS: </td><td><div class='input text'> <span id='lblAddrPrev' style='width:450px;color: #0093B2;font-weight:bold;'>" + previousOwnerAddr + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td><span style='margin-left:5px;color:#000;'>CITY:</span> </td><td><div class='input text'> <span id='lblCityPrev' style='width:150px;color: #0093B2;font-weight:bold;'>" + previousOwnerCity + "</span></div></td><td> STATE:</td><td><div class='input select'> ";
body = body + " <span id='Label1' style='color: #0093B2;font-weight:bold;'>" + previousOwnerState + "</span> ";
body = body + " </div></td><td> ZIP:</td><td><div class='input text'> <span id='lblZipPrev' style='width:50px;color: #0093B2;font-weight:bold;'>" + previousOwnerZip + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td style='white-space:nowrap;'> Date Sold:</td><td><div class='input text'><span id='lblDdatesold' style='width:150px;color: #0093B2;font-weight:bold;'>" + dteSold + "</span></div></td>";
body = body + " <td style='white-space:nowrap;'> Sale Price:</td><td><div class='input text'><span id='lblSalePrice' style='width:150px;color: #0093B2;font-weight:bold;'>" + sPrice + "</span></div></td>";
body = body + " </tr> ";
body = body + " <tr>";
body = body + " <td style='white-space:nowrap;'> Description:</td><td><div class='input textarea'><span id='lblDescription' TextMode='MultiLine' style='width:750px;color: #0093B2;font-weight:bold;'>" + descr + "</span></div></td>";
body = body + " </tr> ";
body = body + " </table>";
body = body + " <table style='width:90%; text-align:left;border-left:solid;border-right:solid;border-bottom:solid'>";
body = body + " <tr>";
body = body + " <td border='0'>";
body = body + " <table border='0' >";
body = body + " <tr>";
body = body + " <th>";
body = body + " If you sold or traded your aircraft and did not own on January 1";
body = body + " this year, this section should be completed in order for the items";
body = body + " to be removed from your account.<br />";
body = body + " </th>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " <td border='0' width='50%' style='margin-left:400px;'>";
body = body + " <table border='0'>";
body = body + " <tr>";
body = body + " <td>";
body = body + " <table border='0' width='90%'>";
body = body + " <tr>";
body = body + " <td>NAME:</td><td><div class='input text'> <span id='lblPurchOnwer' style='width:450px;color: #0093B2;font-weight:bold;'>" + buyerfullName + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td>ADDRESS:</td><td><div class='input text'> <span id='lblPurcAddr' style='width:450px;color: #0093B2;font-weight:bold;'>" + buyerAddr + "</span></div></td>";
body = body + " </tr>";
body = body + " <tr>";
body = body + " <td><span style='margin-left:2px;color:#000;'>CITY:</span></td><td><div class='input text'> <span id='lblPurcCity' style='width:150px;color: #0093B2;font-weight:bold;'>" + buyerCity + "</span></div></td><td> STATE:</td><td><div class='input select'> ";
body = body + " <span id='Label4' style='width:150px;color: #0093B2;font-weight:bold;'>" + buyerState + "</span> ";
body = body + " </div></td><td> ZIP:</td><td><div class='input text'> <span id='lblPurcZip' style='width:50px;color: #0093B2;font-weight:bold;'>" + buyerZip + "</span></div></td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + " <table style='border-collapse: collapse;width:90%; border: 1px solid black;'>";
body = body + " <tr>";
body = body + " <td>";
body = body + " Is there anything functionally wrong with your aircraft?<br />";
body = body + " <span id='Label3' style='color: #0093B2;font-weight:bold;'>" + aircraftIssues + "</span><br />";
body = body + " List anything functionally wrong with your aircraft:";
body = body + "<div class='input textarea'> <span id='lblfunctionalIsses' TextMode='MultiLine' style='width:800px;color: #0093B2;font-weight:bold;'>" + issueDetails + "</span></div>";
body = body + " </td>";
body = body + " </tr>";
body = body + " </table>";
body = body + "<br /><br />";
body = body + " <table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td>";
body = body + "<br /><span style='font-size:3.0em;margin-left:400px;font-weight:bold;'>Taxpayer'S DECLARATION</span><br />";
body = body + "“I do solemnly swear, or affirm, that I have carefully read (or have heard read) and have duly considered the questions propounded in the foregoing tax list, and that";
body = body + "the value placed by me on the property listed as shown, is the true market value there of, and I further swear, or affirm, that I returned, for the purpose of being taxed";
body = body + "thereon, every species of inventory that I own in my right, or have control of, either as agent, executor, administrator, or otherwise; and in making this application,";
body = body + "for the purpose of being taxed thereon, I have not attempted, either by transferring my property to another or by any other means, to evade the laws governing";
body = body + "taxation in this state. I do further swear, or affirm, that in making this application, I have done so by estimating the true worth and value of every species of inventory";
body = body + "contained therein.”<br /><br />";
body = body + " </td>";
body = body + " </tr>";
body = body + "</table>";
body = body + "<table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td style='width:20%'>Title: <input name='txtTitle' type='text' id='txtTitle' style='color: #0093B2;font-weight:bold;' />" + lblTitle.Text + "</td><td style='width:20%'>Preparer Name: <input id='txtpreparerName' style='color: #0093B2;font-weight:bold;' />" + lblpreparerName.Text + "</td><td style='width:20%'>Email: <input name='txtEmail' type='text' id='txtEmail' style='color: #0093B2;font-weight:bold;' />" + lblEmail.Text + "</td><td style='width:20%'>Date: <span id='signDate' style='color: #0093B2;font-weight:bold;'>" + lblSignDate.Text + "</span></td>";
body = body + " </tr>";
body = body + " </table><br /><br />";
//Address of email sender
string yourEmail = txtEmail.Text;
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add(yourEmail);
//msg.CC.Add(ccEmail)
//Configure the address we are sending the mail from
MailAddress fromEmail = new MailAddress("myname@yahoo.com", "Jane Doe");
msg.From = fromEmail;
//Append their name in the beginning of the subject
msg.Subject = "Form Completion Notification";
//To embed image in email
msg.Body = (body;
msg.IsBodyHtml = true;
//Configure an SmtpClient to send the mail.
SmtpClient client = new SmtpClient("1xx.3x.1xx.1xx");
//IT-EXCH10-WP1
client.EnableSsl = false;
////Display completed form to users
FillSummary();
//Send the msg
client.Send(msg);
}
DataReader.Read will read each rows of select query result set, so each time the read occurs it rewrite the values of variable and that the reason you are seeing only the last row value. One option is to create a
comma separated string for each columns and they display that in the table.
I think you could also try to put your body to the while().
For example:
string body = "<br />";
while (dr.Read())
{
pin = dr.GetInt32(0);
tpfullname = dr.GetString(1);
regaddr = dr.GetString(2);
...
...
...
email = dr.GetString(46);
body = body + " <table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
...
...
...
body = body + " </table><br /><br />";
body = body + " <br /><br />";
}
After the loop ends, the body will also have the same data.
Best Regards,
Billy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Though, not the way I would have liked it but I will take it.
First, I wanted this piece at the top to display only one:
string body = "<br />";
body = body + " <table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td style='width:30%;vertical-align: text-top;font-weight:normal;text-align:center;color:gainsboro'>FOR OFFICE ONLY</td>";
body = body + " <td style='width:70%;'><div class='auto-style7'><span style='font-weight:bold;color:#4b4b4b;'>AIRCRAFT PERSONAL PROPERTY TAX RETURN</span><br />";
body = body + " <span style='color:#4b4b4b;'>This Return will be considered Public Information and Open for Public Inspection<br />";
body = body + " Return completed form to address listed below.</span></div></td>";
body = body + "</tr>";
and this piece near the bottom to dislay only once:
body = body + " <table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td>";
body = body + "<br /><span style='font-size:3.0em;margin-left:400px;font-weight:bold;'>Taxpayer'S DECLARATION</span><br />";
body = body + "“I do solemnly swear, or affirm, that I have carefully read (or have heard read) and have duly considered the questions propounded in the foregoing tax list, and that";
body = body + "the value placed by me on the property listed as shown, is the true market value there of, and I further swear, or affirm, that I returned, for the purpose of being taxed";
body = body + "thereon, every species of inventory that I own in my right, or have control of, either as agent, executor, administrator, or otherwise; and in making this application,";
body = body + "for the purpose of being taxed thereon, I have not attempted, either by transferring my property to another or by any other means, to evade the laws governing";
body = body + "taxation in this state. I do further swear, or affirm, that in making this application, I have done so by estimating the true worth and value of every species of inventory";
body = body + "contained therein.”<br /><br />";
body = body + " </td>";
body = body + " </tr>";
body = body + "</table>";
body = body + "<table border='1' style='width:90%; text-align:left'>";
body = body + " <tr>";
body = body + " <td style='width:20%'>Title: <input name='txtTitle' type='text' id='txtTitle' style='color: #0093B2;font-weight:bold;' />" + lblTitle.Text + "</td><td style='width:20%'>Preparer Name: <input id='txtpreparerName' style='color: #0093B2;font-weight:bold;' />" + lblpreparerName.Text + "</td><td style='width:20%'>Email: <input name='txtEmail' type='text' id='txtEmail' style='color: #0093B2;font-weight:bold;' />" + lblEmail.Text + "</td><td style='width:20%'>Date: <span id='signDate' style='color: #0093B2;font-weight:bold;'>" + lblSignDate.Text + "</span></td>";
body = body + " </tr>";
body = body + " </table><br /><br />";
Yes its possible. You need to keep the repeating portion inside your while loop and for the portion which needs to be displayed once keep it outside of the while loop.
Member
255 Points
1159 Posts
How to email contents of preview page
Oct 25, 2017 08:53 PM|simflex|LINK
Greetings experts,
I have a very long code that we provide to users to preview their data before submitting to the database.
Right now, when users complete the form and submit to the database, they receive a copy of the completed form from preview page.
The issue is that this form can contain multiple sections.
For instance, if the first section displays:
Name: Jane Joe,
Address: 123 worker way,
phone: 111-111-1111
email: jane.doe@yahoo.com
zip: 45601
etc, user can complete this form, click Add another row to complete another section say:
Name: Paul Manning,
Address: 790 Andrews Blvd,
phone: 222-333-4444
email: pmaning@yahoo.com
zip: 47694
Once user submits the form and receives an email, only the second section with Paul Manning gets sent to the user via email.
Is there a way to loop this so user receives all the forms completed?
The above data is just an example but the code itself is very long.
Any suggestions is greatly appreciated.
Contributor
2260 Points
815 Posts
Re: How to email contents of preview page
Oct 26, 2017 07:15 AM|Billy Liu|LINK
Hi simflex,
Since you can save both sections into database, I think you must have looped this, right ?
You could try to use the same data for your email.
Or please show me your code, so that I can help you more efficient.
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
255 Points
1159 Posts
Re: How to email contents of preview page
Oct 26, 2017 02:54 PM|simflex|LINK
Hi Billy,
I apologize for the late response. I had an emergency yesterday that literally kept me up all night.
About your solution, I am actually pulling the data from the database.
The issue is the way the data is used in the tables that is wrapped with body as shown on the code below.
I grabbed the code from preview page using VIEW SOURCE.
I am not sure of a better way of using the actual asp.net markup from preview page:
All-Star
50831 Points
9895 Posts
Re: How to email contents of preview page
Oct 26, 2017 03:03 PM|A2H|LINK
DataReader.Read will read each rows of select query result set, so each time the read occurs it rewrite the values of variable and that the reason you are seeing only the last row value. One option is to create a comma separated string for each columns and they display that in the table.
Aje
My Blog | Dotnet Funda
Member
255 Points
1159 Posts
Re: How to email contents of preview page
Oct 26, 2017 05:07 PM|simflex|LINK
Ok, I thought if (dr.Read()) reads just one value and while (dr.Read()) reads all values associated with a fieldname.
A larger issue though is to ensure that the form is laid out correctly.
I would have liked to have shown a screenshot but I don't have a url to post it from.
The screenshot will show how they are broken down by section.
Contributor
2260 Points
815 Posts
Re: How to email contents of preview page
Oct 27, 2017 09:08 AM|Billy Liu|LINK
Hi simflex,
I think you could also try to put your body to the while().
For example:
After the loop ends, the body will also have the same data.
Best Regards,
Billy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
255 Points
1159 Posts
Re: How to email contents of preview page
Oct 27, 2017 08:01 PM|simflex|LINK
Hey Billy, it WORKED!!!!!
Though, not the way I would have liked it but I will take it.
First, I wanted this piece at the top to display only one:
and this piece near the bottom to dislay only once:
Is it possible?
Thanks so much for your help
All-Star
50831 Points
9895 Posts
Re: How to email contents of preview page
Oct 27, 2017 08:31 PM|A2H|LINK
Yes its possible. You need to keep the repeating portion inside your while loop and for the portion which needs to be displayed once keep it outside of the while loop.
Aje
My Blog | Dotnet Funda
Member
255 Points
1159 Posts
Re: How to email contents of preview page
Oct 27, 2017 08:42 PM|simflex|LINK
I tried that before posting but let me try again in case I missed something.
Member
255 Points
1159 Posts
Re: How to email contents of preview page
Oct 27, 2017 08:54 PM|simflex|LINK
It worked this time.
I think the reason is I moved the bottom portion out but did not move outside the loop the top portion.
Thanks guys for all the help.