Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I am using stringbuilder to create a printscreen and email. It is working well. Now I am trying to create a CSV file too. Sothat we can insert the data in SQL Database.

At the moment it does not create the csv yet. It is only printing on Screen and sending email. I want to add more code which will send me a CSV file when user fillouts the application.

Can you pls look at the code and help me where should i add new code to achive that?


Thanks


code looks like as below
using System;   
using System.Web.Configuration;   
using System.Net.Mail;   
using System.Security.Cryptography.Pkcs;   
using System.Security.Cryptography.X509Certificates;   
using System.Text;   
using System.IO;   
using System.Data;   
using System.Data.SqlClient;   
using System.Web.Services;   
using System.Web.DataAccess;   
using System.Web;   
using System.Collections.Specialized;   
using System.Net;   
  
  
namespace HomeTrustELVForm   
{   
public partial class sendApplication : System.Web.UI.Page   
{   
protected void Page_Load(object sender, EventArgs e)   
{   
if (Request.HttpMethod.ToUpper() == "POST")   
{   
if (Session["submitted"] == null)   
{   
Response.Expires = -1;   
Response.AddHeader("Pragma", "no-cache");   
Response.Cache.SetNoStore();   
Response.Cache.SetNoServerCaching();   
SmtpClient smtpClient = new SmtpClient(WebConfigurationManager.AppSettings["smtpServer"]);   
MailAddress fromAddress = new MailAddress(WebConfigurationManager.AppSettings["appFromEmail"]);   
MailAddress toAddress;   
MailMessage objEmail;   
X509Certificate2 cert;   
String province = "";   
String applicationType = "";   
String refferedBy = "";   
String phone = "";   
String lookingFor = "";   
String other = "";   
String amount = "";   
String multiple = "";   
String coapplicant = "";   
String consent = "";   
String thirdParty = "";   
String agree = "";   
String principalResidence = "";   
String sin = "";   
String maritalStatus = "";   
String firstName = "";   
String initials = "";   
String lastName = "";   
String birthDay = "";   
String maidenName = "";   
String address = "";   
String city = "";   
String postalCode = "";   
String homePhone = "";   
String cellPhone = "";   
String businessPhone = "";   
String email = "";   
String monthlyIncome = "";   
String otherIncome = "";   
String employer = "";   
String employeeAddress = "";   
String employerSuiteNum = "";   
String employerCity = "";   
String employerProvince = "";   
String employerPostalCode = "";   
String occupation = "";   
String employer2Yrs = "";   
String numYears = "";   
String prevEmployer = "";   
String propertyValue = "";   
String propertyType = "";   
String purchaseDate = "";   
String origPurchasePrice = "";   
String lender = "";   
String mortgagePayment = "";   
String mortgageBalance = "";   
String maturityDate = "";   
String secondMortgageLender = "";   
String MonthlySecondMortgagePayment = "";   
String secondMortgageBalance = "";   
String secondMortgageMaturityDate = "";   
String propertyTax = "";   
String coPrincipalResidence = "";   
String coSin = "";   
String coMaritalStatus = "";   
String coFirstName = "";   
String coInitials = "";   
String coLastname = "";   
String coBirthDate = "";   
String coMothersMaiden = "";   
String coAddress = "";   
String coCity = "";   
String coProvince = "";   
String coPostalCode = "";   
String coHomePhone = "";   
String coCellPhone = "";   
String coBusinessPhone = "";   
String coEmail = "";   
String coMonthlyIncome = "";   
String coOtherIncome = "";   
String coCurrentEmployer = "";   
String coEmployerAddress = "";   
String coEmployerSuiteNum = "";   
String coEmployerCity = "";   
String coEmployerProv = "";   
String coEmployerPostalCode = "";   
String coOccupation = "";   
String coEmployed2yrs = "";   
String coNumYears = "";   
String coPrevEmployer = "";   
  
                     // google analytics variables   
                    String source = "";   
                    String medium = "";   
                    String term = "";   
                    String content = "";   
                    String campaign = "";   
String csegment = "";   
                    String formFrom = "";   
  
  
if (Request.Params["province"] != null) province = Request.Params["province"].Trim();   
if (Request.Params["applicationType"] != null) applicationType = Request.Params["applicationType"].Trim();   
if (Request.Params["refferedBy"] != null) refferedBy = Request.Params["refferedBy"].Trim();   
if (Request.Params["phone"] != null) phone = Request.Params["phone"].Trim();   
if (Request.Params["lookingFor"] != null) lookingFor = Request.Params["lookingFor"].Trim();   
if (Request.Params["other"] != null) other = Request.Params["other"].Trim();   
if (Request.Params["amount"] != null) amount = Request.Params["amount"].Trim();   
if (Request.Params["multiple"] != null) multiple = Request.Params["multiple"].Trim();   
if (Request.Params["coapplicant"] != null) coapplicant = Request.Params["coapplicant"].Trim();   
if (Request.Params["consent"] != null) consent = Request.Params["consent"].Trim();   
if (Request.Params["thirdParty"] != null) thirdParty = Request.Params["thirdParty"].Trim();   
if (Request.Params["agree"] != null) agree = Request.Params["agree"].Trim();   
if (Request.Params["principalResidence"] != null) principalResidence = Request.Params["principalResidence"].Trim();   
if (Request.Params["sin"] != null) sin = Request.Params["sin"].Trim();   
if (Request.Params["maritalStatus"] != null) maritalStatus = Request.Params["maritalStatus"].Trim();   
if (Request.Params["firstName"] != null) firstName = Request.Params["firstName"].Trim();   
if (Request.Params["initials"] != null) initials = Request.Params["initials"].Trim();   
if (Request.Params["lastName"] != null) lastName = Request.Params["lastName"].Trim();   
if (Request.Params["birthDay"] != null) birthDay = Request.Params["birthDay"].Trim();   
if (Request.Params["maidenName"] != null) maidenName = Request.Params["maidenName"].Trim();   
if (Request.Params["address"] != null) address = Request.Params["address"].Trim();   
if (Request.Params["city"] != null) city = Request.Params["city"].Trim();   
if (Request.Params["postalCode"] != null) postalCode = Request.Params["postalCode"].Trim();   
if (Request.Params["homePhone"] != null) homePhone = Request.Params["homePhone"].Trim();   
if (Request.Params["cellPhone"] != null) cellPhone = Request.Params["cellPhone"].Trim();   
if (Request.Params["businessPhone"] != null) businessPhone = Request.Params["businessPhone"].Trim();   
if (Request.Params["email"] != null) email = Request.Params["email"].Trim();   
if (Request.Params["monthlyIncome"] != null) monthlyIncome = Request.Params["monthlyIncome"].Trim();   
if (Request.Params["otherIncome"] != null) otherIncome = Request.Params["otherIncome"].Trim();   
if (Request.Params["employer"] != null) employer = Request.Params["employer"].Trim();   
if (Request.Params["employeeAddress"] != null) employeeAddress = Request.Params["employeeAddress"].Trim();   
if (Request.Params["employerSuiteNum"] != null) employerSuiteNum = Request.Params["employerSuiteNum"].Trim();   
if (Request.Params["employerCity"] != null) employerCity = Request.Params["employerCity"].Trim();   
if (Request.Params["employerProvince"] != null) employerProvince = Request.Params["employerProvince"].Trim();   
if (Request.Params["employerPostalCode"] != null) employerPostalCode = Request.Params["employerPostalCode"].Trim();   
if (Request.Params["occupation"] != null) occupation = Request.Params["occupation"].Trim();   
if (Request.Params["employer2Yrs"] != null) employer2Yrs = Request.Params["employer2Yrs"].Trim();   
if (Request.Params["numYears"] != null) numYears = Request.Params["numYears"].Trim();   
if (Request.Params["prevEmployer"] != null) prevEmployer = Request.Params["prevEmployer"].Trim();   
if (Request.Params["propertyValue"] != null) propertyValue = Request.Params["propertyValue"].Trim();   
if (Request.Params["propertyType"] != null) propertyType = Request.Params["propertyType"].Trim();   
if (Request.Params["purchaseDate"] != null) purchaseDate = Request.Params["purchaseDate"].Trim();   
if (Request.Params["origPurchasePrice"] != null) origPurchasePrice = Request.Params["origPurchasePrice"].Trim();   
if (Request.Params["lender"] != null) lender = Request.Params["lender"].Trim();   
if (Request.Params["mortgagePayment"] != null) mortgagePayment = Request.Params["mortgagePayment"].Trim();   
if (Request.Params["mortgageBalance"] != null) mortgageBalance = Request.Params["mortgageBalance"].Trim();   
if (Request.Params["maturityDate"] != null) maturityDate = Request.Params["maturityDate"].Trim();   
if (Request.Params["secondMortgageLender"] != null) secondMortgageLender = Request.Params["secondMortgageLender"].Trim();   
if (Request.Params["MonthlySecondMortgagePayment"] != null) MonthlySecondMortgagePayment = Request.Params["MonthlySecondMortgagePayment"].Trim();   
if (Request.Params["secondMortgageBalance"] != null) secondMortgageBalance = Request.Params["secondMortgageBalance"].Trim();   
if (Request.Params["secondMortgageMaturityDate"] != null) secondMortgageMaturityDate = Request.Params["secondMortgageMaturityDate"].Trim();   
if (Request.Params["propertyTax"] != null) propertyTax = Request.Params["propertyTax"].Trim();   
if (Request.Params["coPrincipalResidence"] != null) coPrincipalResidence = Request.Params["coPrincipalResidence"].Trim();   
if (Request.Params["coSin"] != null) coSin = Request.Params["coSin"].Trim();   
if (Request.Params["coMaritalStatus"] != null) coMaritalStatus = Request.Params["coMaritalStatus"].Trim();   
if (Request.Params["coFirstName"] != null) coFirstName = Request.Params["coFirstName"].Trim();   
if (Request.Params["coInitials"] != null) coInitials = Request.Params["coInitials"].Trim();   
if (Request.Params["coLastname"] != null) coLastname = Request.Params["coLastname"].Trim();   
if (Request.Params["coBirthDate"] != null) coBirthDate = Request.Params["coBirthDate"].Trim();   
if (Request.Params["coMothersMaiden"] != null) coMothersMaiden = Request.Params["coMothersMaiden"].Trim();   
if (Request.Params["coAddress"] != null) coAddress = Request.Params["coAddress"].Trim();   
if (Request.Params["coCity"] != null) coCity = Request.Params["coCity"].Trim();   
if (Request.Params["coProvince"] != null) coProvince = Request.Params["coProvince"].Trim();   
if (Request.Params["coPostalCode"] != null) coPostalCode = Request.Params["coPostalCode"].Trim();   
if (Request.Params["coHomePhone"] != null) coHomePhone = Request.Params["coHomePhone"].Trim();   
if (Request.Params["coCellPhone"] != null) coCellPhone = Request.Params["coCellPhone"].Trim();   
if (Request.Params["coBusinessPhone"] != null) coBusinessPhone = Request.Params["coBusinessPhone"].Trim();   
if (Request.Params["coEmail"] != null) coEmail = Request.Params["coEmail"].Trim();   
if (Request.Params["coMonthlyIncome"] != null) coMonthlyIncome = Request.Params["coMonthlyIncome"].Trim();   
if (Request.Params["coOtherIncome"] != null) coOtherIncome = Request.Params["coOtherIncome"].Trim();   
if (Request.Params["coCurrentEmployer"] != null) coCurrentEmployer = Request.Params["coCurrentEmployer"].Trim();   
if (Request.Params["coEmployerAddress"] != null) coEmployerAddress = Request.Params["coEmployerAddress"].Trim();   
if (Request.Params["coEmployerSuiteNum"] != null) coEmployerSuiteNum = Request.Params["coEmployerSuiteNum"].Trim();   
if (Request.Params["coEmployerCity"] != null) coEmployerCity = Request.Params["coEmployerCity"].Trim();   
if (Request.Params["coEmployerProv"] != null) coEmployerProv = Request.Params["coEmployerProv"].Trim();   
if (Request.Params["coEmployerPostalCode"] != null) coEmployerPostalCode = Request.Params["coEmployerPostalCode"].Trim();   
if (Request.Params["coOccupation"] != null) coOccupation = Request.Params["coOccupation"].Trim();   
if (Request.Params["coEmployed2yrs"] != null) coEmployed2yrs = Request.Params["coEmployed2yrs"].Trim();   
if (Request.Params["coNumYears"] != null) coNumYears = Request.Params["coNumYears"].Trim();   
if (Request.Params["coPrevEmployer"] != null) coPrevEmployer = Request.Params["coPrevEmployer"].Trim();   
  
                    if (Request.Params["source"] != null) source = Request.Params["source"].Trim();   
                    if (Request.Params["medium"] != null) medium = Request.Params["medium"].Trim();   
                    if (Request.Params["term"] != null) term =  Request.Params["term"].Trim();   
                    if (Request.Params["content"] != null) content = Request.Params["content"].Trim();   
                    if (Request.Params["campaign"] != null) campaign = Request.Params["campaign"].Trim();   
                    if (Request.Params["csegment"] != null) csegment = Request.Params["csegment"].Trim();   
                    if (Request.Params["formFrom"] != null) formFrom = Request.Params["formFrom"].Trim();   
  
                
<STRONG><U>'Printing on SCREEN</U></STRONG>   
  
                    String txtMessage = ""  
                            + "------------------------------------------------------------------------<br/>"  
                            + "EQUITYLINE VISA CARD - ONLINE APPLICATION <br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "PROVINCE: " + province + "<br/>"  
                            + "SOURCE: " + applicationType + "<br/>"  
                            + "REFERRED BY: " + refferedBy + "<br/>"  
                            + "PHONE: " + phone + "<br/>"  
                            + "PURPOSE: " + lookingFor + "<br/>"  
                            + "PURPOSE OTHER: " + other + "<br/>"  
                            + "CREDIT LIMIT: " + amount + "<br/>"  
                            + "DID MORE THAN ONE PERSON SIGN FOR THE PURCHASE OF THIS HOME: " + multiple + " <br/>"  
                            + "RELATIONSHIP TO CO-APPLICANT: " + coapplicant + "<br/>"  
                            + "CO-BORROWER DISCLOSURE: " + consent + "<br/>"  
                            + "NOT ACTING ON BEHALF OF 3RD PARTY: " + thirdParty + "<br/>"  
                            + "AGREED TO TERMS: " + agree + "<br/>"  
                            + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "PLEASE TELL US ABOUT YOURSELF<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "APPLICANT'S PRINCIPAL RESIDENCE?: " + principalResidence + "<br/>"  
                            + "SIN: " + sin + "<br/>"  
                            + "MARITAL STATUS: " + maritalStatus + "<br/>"  
                            + "FIRST NAME: " + firstName + "<br/>"  
                            + "INITIAL: " + initials + "<br/>"  
                            + "LAST NAME: " + lastName + "<br/>"  
                            + "DATE OF BIRTH: " + birthDay + "<br/>"  
                            + "MOTHER'S MAIDEN NAME: " + maidenName + "<br/>"  
                            + "ADDRESS: " + address + "<br/>"  
                            + "CITY: " + city + "<br/>"  
                            + "PROVINCE: " + province + "<br/>"  
                            + "POSTAL CODE: " + postalCode + "<br/>"  
                            + "HOME PHONE: " + homePhone + "<br/>"  
                            + "MOBILE PHONE: " + cellPhone + "<br/>"  
                            + "BUSINESS PHONE: " + businessPhone + "<br/>"  
                            + "EMAIL: " + email + "<br/>"  
                            + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "PLEASE TELL US ABOUT YOUR INCOME<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "MONTHLY INCOME: " + monthlyIncome + "<br/>"  
                            + "OTHER INCOME: " + otherIncome + "<br/>"  
                            + "CURRENT EMPLOYER: " + employer + "<br/>"  
                            + "EMPLOYER'S ADDRESS: " + employeeAddress + "<br/>"  
                            + "EMPLOYER'S SUITE: " + employerSuiteNum + "<br/>"  
                            + "EMPLOYER'S CITY: " + employerCity + "<br/>"  
                            + "EMPLOYER'S PROVINCE: " + employerProvince + "<br/>"  
                            + "EMPLOYER'S POSTAL CODE: " + employerPostalCode + "<br/>"  
                            + "OCCUPATION: " + occupation + "<br/>"  
                            + "MORE THAN TWO YEARS TO CURRENT EMPLOYER: " + employer2Yrs + "<br/>"  
                            + "YEARS/MONTHS THERE: " + numYears + "<br/>"  
                            + "PREVIOUS EMPLOYER: " + prevEmployer + "<br/>"  
                            + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "PLEASE TELL US ABOUT YOUR HOME<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "PROPERTY VALUE: " + propertyValue + "<br/>"  
                            + "TYPE OF PROPERTY: " + propertyType + "<br/>"  
                            + "PURCHASE DATE: " + purchaseDate + "<br/>"  
                            + "WHAT DID YOU ORIGINALLY PAY FOR YOUR HOME: " + origPurchasePrice + "<br/>"  
                            + "FIRST MORTGAGE LENDER (INSTITUTION NAME AND PHONE NUMBER): " + lender + "<br/>"  
                            + "FIRST MORTGAGE MONTHLY PAYMENT: " + mortgagePayment + "<br/>"  
                            + "FIRST MORTGAGE BALANCE: " + mortgageBalance + "<br/>"  
                            + "MATURITY DATE: " + maturityDate + "<br/>"  
                            + "SECOND MORTGAGE LENDER, IF APPLICABLE (INSTITUTION NAME AND PHONE NUMBER): " + secondMortgageLender + "<br/>"  
                            + "SECOND MORTGAGE MONTHLY PAYMENT: " + MonthlySecondMortgagePayment + "<br/>"  
                            + "SECOND MORTGAGE BALANCE: " + secondMortgageBalance + "<br/>"  
                            + "SECOND MORTGAGE MATURITY DATE: " + secondMortgageMaturityDate + "<br/>"  
                            + "ANNUAL PROPERTY TAXES: " + propertyTax + "<br/>"  
                            + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "CO-APPLICANT INFORMATION<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "CO-APPLICANT'S PRINCIPAL RESIDENCE?: " + coPrincipalResidence + "<br/>"  
                            + "SIN: " + coSin + "<br/>"  
                            + "MARITAL STATUS: " + coMaritalStatus + "<br/>"  
                            + "FIRST NAME: " + coFirstName + "<br/>"  
                            + "INITIAL: " + coInitials + "<br/>"  
                            + "LAST NAME: " + coLastname + "<br/>"  
                            + "DATE OF BIRTH: " + coBirthDate + "<br/>"  
                            + "MOTHER'S MAIDEN NAME: " + coMothersMaiden + "<br/>"  
                            + "ADDRESS: " + coAddress + "<br/>"  
                            + "CITY: " + coCity + "<br/>"  
                            + "PROVINCE: " + coProvince + "<br/>"  
                            + "POSTAL CODE: " + coPostalCode + "<br/>"  
                            + "HOME PHONE: " + coHomePhone + "<br/>"  
                            + "MOBILE PHONE: " + coCellPhone + "<br/>"  
                            + "BUSINESS PHONE: " + coBusinessPhone + "<br/>"  
                            + "EMAIL: " + coEmail + "<br/>"  
                            + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "CO-APPLICANT INCOME<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "MONTHLY INCOME: " + coMonthlyIncome + "<br/>"  
                            + "OTHER INCOME: " + coOtherIncome + "<br/>"  
                            + "CURRENT EMPLOYER: " + coCurrentEmployer + "<br/>"  
                            + "EMPLOYER'S ADDRESS: " + coEmployerAddress + "<br/>"  
                            + "EMPLOYER'S SUITE: " + coEmployerSuiteNum + "<br/>"  
                            + "EMPLOYER'S CITY: " + coEmployerCity + "<br/>"  
                            + "EMPLOYER'S PROVINCE: " + coEmployerProv + "<br/>"  
                            + "EMPLOYER'S POSTAL CODE: " + coEmployerPostalCode + "<br/>"  
                            + "OCCUPATION: " + coOccupation + "<br/>"  
                            + "MORE THAN TWO YEARS TO CURRENT EMPLOYER: " + coEmployed2yrs + "<br/>"  
                            + "YEARS/MONTHS THERE: " + coNumYears + "<br/>"  
                            + "PREVIOUS EMPLOYER: " + coPrevEmployer + "<br/>"       
                            + "<br/>";   
                       
                    String txtMessage2 = ""  
                            + "------------------------------------------------------------------------<br/>"  
                            + "ELV WEB INQUIRY - ADWORDS " + "<br/>"  
                            + "------------------------------------------------------------------------<br/>"  
                            + "<br/>"  
                            + "MARKETING CODE: " + "ADWORDS " + "- " + formFrom +  "<br/>"  
                            + "SOURCE: " + source + "<br/>"  
                            + "KEYWORD: " + term + "<br/>"  
                            + "MEDIUM: " + medium + "<br/>"  
                            + "CAMPAIGN: " + campaign + "<br/>"  
                            + "AD CONTENT: " + content + "<br/>"  
+ "csegment" + csegment + "<br/>"  
                            + "<br/>";   
  
  
if (applicationType.ToLower().CompareTo("broker") == 0)   
{   
toAddress = new MailAddress(WebConfigurationManager.AppSettings["brokerAppToEmail"]);   
cert = new X509Certificate2(Server.MapPath(WebConfigurationManager.AppSettings["brokerCertFile"]));   
}   
else  
{   
toAddress = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["generalAppToEmail"]);   
cert = new X509Certificate2(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["generalCertFile"]));   
}   
objEmail = new MailMessage(fromAddress, toAddress);   
objEmail.Subject = WebConfigurationManager.AppSettings["appSubject"];   
objEmail.Priority = MailPriority.High;   
objEmail.IsBodyHtml = true;   
  
// Encrypt the email   
StringBuilder sbMessage = new StringBuilder();   
sbMessage.AppendLine("Content-Type: text/html; charset=\"iso-8859-1\"");   
sbMessage.AppendLine("Content-Transfer-Encoding: 7bit");   
sbMessage.AppendLine();   
  
  
                    if (formFrom.CompareTo("DC") == 0)   
                    {   
                        sbMessage.Append(txtMessage + txtMessage2);   
                    }   
                    else if (formFrom.CompareTo("BFS") == 0)   
                    {   
                        sbMessage.Append(txtMessage + txtMessage2);   
                         
                    }   
                    else  
                    {   
                        sbMessage.Append(txtMessage);   
                    }   
                      
  
byte[] aMessage = Encoding.ASCII.GetBytes(sbMessage.ToString());   
EnvelopedCms ECms = new EnvelopedCms(new ContentInfo(aMessage));   
CmsRecipient Recipient = new CmsRecipient(SubjectIdentifierType.IssuerAndSerialNumber, cert);   
ECms.Encrypt(Recipient);   
byte[] aEncryptedMessage = ECms.Encode();   
MemoryStream ms = new MemoryStream(aEncryptedMessage);   
AlternateView av = new AlternateView(ms, "application/pkcs7-mime; smime-type=signed-data;name=smime.p7m");   
objEmail.AlternateViews.Add(av);   
  
smtpClient.ClientCertificates.Add(cert);   
smtpClient.Send(objEmail);   
Session["submitted"] = true;   
  
try  
{   
DatabaseHelper.GetDataRow("proc_logApplication"  
, new SqlParameter("@source", applicationType)   
, new SqlParameter("@province", province)   
, new SqlParameter("@city", city)   
, new SqlParameter("@purpose", lookingFor.ToLower() == "other" ? other : lookingFor)   
, new SqlParameter("@brokerName", refferedBy)   
, new SqlParameter("@lastName", lastName)   
);   
}   
catch (Exception exc)   
{   
Response.Write("Log failure: " + exc.ToString());   
}   
  
  
appform.Text = txtMessage;   
if (consent.Substring(0, 2).ToLower().CompareTo("no") == 0)   
{   
statementCopy.Text = "You have chosen to receive <u>separate copies of Statements</u>.";   
}   
else  
{   
statementCopy.Text = "You have chosen to receive <u>only one copy of Statements</u>.";   
}   
ThankYou_Panel.Visible = true;   
}   
else  
{   
problemMessage.Text = "You have already submitted an application.  If you wish to submit another application, please close your browser and revisit our site.";   
Problem_Panel.Visible = true;   
}   
}   
else  
{   
problemMessage.Text = "";   
Problem_Panel.Visible = true;   
}   
}   
}   
}  
Posted
Updated 14-Dec-09 4:38am
v3

1 solution

I would put it anywhere other than in that monster method!

Best ploy would be to refactor this into separate methods. eg.

C#
this.GatherParams()
this.GeneratePrintOutput()
this.GenerateAndSendEmail()
this.GenerateAndSendCSV()


Looks like you have the Emailing sussed so sending the csv to yourself is no problem. The csv can obviously be generated direct from the params, just concatenating the string values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900