• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

How to incorporate this code into an aspx email script

I've been asked to help make the content of an email look a bit better. I created a template and now I need to introduce into into the aspx file that dictates the content.

I'm brand new to this so some of the coding has me a bit baffled. The code is attached. I'm thinking I need to introduce my graphics and outlay after each "if" statement. For example:

  if (type == ORDER)
        {
            mail_body = "<p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has now completed your " +


Right there at "mail_body" is where I want to put my code for my new "look." You can see the look and source code by heading out to http://hihatwebdesign.com/QMS/email.htm.

My question is: How do I insert my HTML code and accommodate the protocols that seem to be in place here. The only content in the code that I have attached that needs to remain intact is:

p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has now completed your " +
                "latest order of files chosen for Quality Assurance review. " +
                "If you have problems accessing the order, have questions about this order, or loan substitutions are needed, " +
                "you may contact <a href=http://www.qcmortgage.com>QMS</a> at 615-591-2528, or send an email to orders@qcmortgage.com.  By clicking " +
                "on the following link, you can access this order: <br>&nbsp;<br>";

            mail_link = "<a href=https://qcmortgage.com/mars2/qcorder.aspx?sid=" + session_id + ">https://qcmortgage.com/mars2/qcorder.aspx?sid=" +
                session_id + "</a> <br><br>&nbsp;<br>" +
                "Comments: " + txtComments.Text + "</p><br/><br/>" +

But I don't how to incorporate that into my template and I don't know if I need to change every " in my HTML code to a single quote.

Can someone solve this mystery for me?
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Text.RegularExpressions;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;
 
public partial class emailsend : System.Web.UI.Page
{
    private const int ORDER = 1;
    private const int REPORT = 2;
    private const int INVOICE = 3;
    int type = 1;
    MailAttachment Attach1 = null;
    String Attach2 = "";
    String Attach3 = "";
    String Attach4 = "";
    String Attach5 = "";
    String Attach6 = "";
    //MailAttachment objattach = new MailAttachment();
    string clientabbr = "";
 
 
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();
        
        String http_referer = null;
        String id = null;
        String sid = null;
        bool isButtonShown = false;
        //if (Request.ServerVariables["HTTP_REFERER"] != null)
        //    http_referer = Request.ServerVariables["HTTP_REFERER"].ToString();
 
        if (Request.QueryString["id"] != null)
            id = Request.QueryString["id"].ToString();
        
        #region
        //if (Request.QueryString["sid"] != null)
        //    sid = Request.QueryString["sid"].ToString();
 
        //if (id != null)
        //{
        //   if (http_referer.Contains("qcmortgage.com") || http_referer.Contains("localhost"))
        //   {
        //       if (Session["showButton"] != null)
        //           isButtonShown = Boolean.Parse(Session["showButton"].ToString());
        //       else if (sid != null)
        //      {
        //          try
        ///          {
        //              id = getOrderHeaderID(sid);
        //          }
        //          catch (Exception ex)
        //          {
        //              //lblMsg.Text = "Error: " + ex.Message + "<br>" + ex.Source;
        //          }
        //      }
        //      else
        //      {
        //          Session.Clear();
        //          Response.Redirect("login.aspx");
        //      }
        //  }
        //  else
        //  {
        //      Session.Clear();
        //      Response.Redirect("unauthorized.aspx");
        //  }
        //}
        //else
        // {
        //    if (sid != null)
        //    {
        //        id = getOrderHeaderID(sid);
        //       if (id == null)
        //       {
        //           Session.Clear();
        //           Response.Redirect("unauthorized.aspx");
        //       }
        //       isButtonShown = false;
        //  }
        //   else
        //    {
        //       Session.Clear();
        //        Response.Redirect("unauthorized.aspx");
        //      }
        //  }
        #endregion
        String companyName = "";
        String id_orderheader = Request.QueryString["id"].ToString();
        #region
        /*String sql2 = "Select Company_Name from OrderHeader where id = " + id_orderheader;
        //fill in blanks
        String connStr2 = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        SqlConnection conn2 = new SqlConnection(connStr2);
        conn2.Open();
        SqlCommand cmd2 = new SqlCommand(sql2, conn2);
        SqlDataReader rdr2 = cmd2.ExecuteReader(CommandBehavior.CloseConnection);
        if (rdr2.Read())
        {
            companyName = rdr2["Company_Name"].ToString();
        }*/
        /*String sql = "Select * from Clients where Company_Name LIKE '%" + companyName + "%'";
        String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand cmd = new SqlCommand(sql, conn);
        SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        if (rdr.Read())
        {
            String email = rdr["Contact1_Email"].ToString();
            if (email == null) email = "";
            txtContactEmail1.Text = email;
 
            String email2 = rdr["Contact2_Email"].ToString();
            if (email == null) email = "";
            txtContactEmail2.Text = email;
 
            String email3 = rdr["Contact3_Email"].ToString();
            if (email == null) email = "";
            txtContactEmail3.Text = email;
        }*/
        #endregion
 
        String sql = "select * from clients where id = (select prnt_id from Orderheader where id = @id)";
        try
        {
            String sql1 = "select * from ORDERHEADER where orderheader_id = " + id_orderheader;
            String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@id", id_orderheader);
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                        {
                            if (!rdr.IsDBNull(26) && rdr.GetBoolean(26))
                                txtContactEmail1.Text = rdr["Contact1_Email"].ToString();
                            if (!rdr.IsDBNull(29) && rdr.GetBoolean(29))
                                txtContactEmail2.Text = rdr["Contact2_Email"].ToString();
                            if (!rdr.IsDBNull(32) && rdr.GetBoolean(32))
                                txtContactEmail3.Text = rdr["Contact3_Email"].ToString();
                            clientabbr = rdr["Client_Abbreviation"].ToString();
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //lblMsg.Text = "Error: " + ex.Message + "<br>" + ex.Source;
            throw ex;
        }
 
    }
 
    private void setAuthorization(String orderheader_id, String session_id, String auth_purpose)
    {
        String sql = "insert into qc_order_auth (auth_number, orderheader_id, auth_purpose) " +
            "values (@auth, @order, @purpose)";
        try
        {
            String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@auth", session_id);
                    cmd.Parameters.AddWithValue("@order", orderheader_id);
                    cmd.Parameters.AddWithValue("@purpose", auth_purpose);
                    cmd.ExecuteNonQuery();
                }
            }
        }
        catch (Exception ex)
        {
            // lblMsg.Text = "Error: " + ex.Message + "<br>" + ex.Source;
            throw ex;
        }
    }
    private String getOrderHeaderID(String session_id)
    {
        String orderHeaderID = null;
        String sql = "select orderheader_id from qc_order_auth where auth_number = @auth " +
            "and auth_purpose = 'INVOICE'";
        try
        {
            String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@auth", session_id);
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                            orderHeaderID = rdr["orderheader_id"].ToString();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //lblMsg.Text = "Error: " + ex.Message + "<br>" + ex.Source;
        }
 
        return orderHeaderID;
    }
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        String referer = null;
        if (Session["referer"] != null)
            referer = Session["referer"].ToString();
        if (referer == null)
            referer = "index.aspx";
        Response.Redirect(referer);
    }
 
    protected void LoadData()
    {
 
    }
 
 
 
 
 
    protected void sendEmail(String id_orderheader, String session_id, int type)
    {
 
        String email1 = "";
        String email2 = "";
        String email3 = "";
        String email_recipients = "";
 
        String mail_body = "";
        String mail_subj = "";
        String mail_link = "";
        String mail_promotion = "";
 
        // get email address first
        String sql = "select * from clients where id = (select prnt_id from Orderheader where id = @id)";
        try
        {
            String sql1 = "select * from ORDERHEADER where orderheader_id = " + id_orderheader;
            String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@id", id_orderheader);
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                        {
                            if (type == ORDER)
                            {
                                if (!rdr.IsDBNull(26) && rdr.GetBoolean(26))
                                    email_recipients = rdr["Contact1_Email"].ToString();
                                if (!rdr.IsDBNull(29) && rdr.GetBoolean(29))
                                    email_recipients += ";" + rdr["Contact2_Email"].ToString();
                                if (!rdr.IsDBNull(32) && rdr.GetBoolean(32))
                                    email_recipients += ";" + rdr["Contact3_Email"].ToString();
                            }
                            else if (type == REPORT)
                            {
                                if (!rdr.IsDBNull(27) && rdr.GetBoolean(27))
                                    email_recipients = rdr["Contact1_Email"].ToString();
                                if (!rdr.IsDBNull(30) && rdr.GetBoolean(30))
                                    email_recipients += ";" + rdr["Contact2_Email"].ToString();
                                if (!rdr.IsDBNull(33) && rdr.GetBoolean(33))
                                    email_recipients += ";" + rdr["Contact3_Email"].ToString();
                            }
                            else
                            {
                                if (!rdr.IsDBNull(28) && rdr.GetBoolean(28))
                                    email_recipients = rdr["Contact1_Email"].ToString();
                                if (!rdr.IsDBNull(31) && rdr.GetBoolean(31))
                                    email_recipients += ";" + rdr["Contact2_Email"].ToString();
                                if (!rdr.IsDBNull(34) && rdr.GetBoolean(34))
                                    email_recipients += ";" + rdr["Contact3_Email"].ToString();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //lblMsg.Text = "Error: " + ex.Message + "<br>" + ex.Source;
            throw ex;
        }
 
        if (type == ORDER)
        {
            mail_body = "<p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has now completed your " +
                "latest order of files chosen for Quality Assurance review. " +
                "If you have problems accessing the order, have questions about this order, or loan substitutions are needed, " +
                "you may contact <a href=http://www.qcmortgage.com>QMS</a> at 615-591-2528, or send an email to orders@qcmortgage.com.  By clicking " +
                "on the following link, you can access this order: <br>&nbsp;<br>";
 
            mail_link = "<a href=https://qcmortgage.com/mars2/qcorder.aspx?sid=" + session_id + ">https://qcmortgage.com/mars2/qcorder.aspx?sid=" +
                session_id + "</a> <br><br>&nbsp;<br>" +
                "Comments: " + txtComments.Text + "</p><br/><br/>" + 
 
		"<b><h1><center><font color='#AF7817'>FREE COMPLIANCE!</font></center></h1><font size='4'>Qdocs.net</b>&#160;&#160;<a href=http://www.qdocs.net>www.qdocs.net </a></font>" +
		"<p>Qdocs.net and Quality Mortgage Services has put together a way for the mortgage professional to receive post-closing mortgage compliance free. " +
		"This is what you get with Qdocs.net and Quality Mortgage Services: <br/>" +
		"<ul><li>A secure facility to keep closed loans and paper palletized and shrink wrapped </li>" +
		"<li>Secure data center and secure FTP uploads</li>"+
		"<li>Disaster Recover Plan for data kept out of state </li>" +
		"<li>Your borrower will have access to his/her closing documents and appraisal</li>"+
		"<li>When your borrower accesses his/her file, you will receive an E-mail notification </li>"+
		"<li>You will have secure web portal access to all files</li>"+
		"<li>All files can be printed or exported but never altered</li>"+
		"<li>You will receive free mortgage compliance</li><br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of closed loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of denied/withdrawn FHA loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 100% Early Payment Defaults(EPDs)<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; Field Review Appraisals free<br/></ul></p>"+
 
		"<br/><font size='4'><b>National Mortgage Appraisers</b>&#160;&#160;<a href=http://www.nationalmortgageappraisers.com>www.nationalmortgageappraisers.com </a></font>"+
		"<p>A database of appraisers associated with high risk loans "+
		"Brokers & Bankers will no longer be able to order appraisals directly from the appraisers. "+
		"How many compliance companies you know own an appraiser company that tracks high risk appraisals?</p>"+
 
		"<p>Quality Mortgage Services provides data from MARS II, Mortgage Analyst Software, so that National Mortgage Appraisers can verify appraisers "+
		"are not associated with fraudulent or high risk loans.  This data is compiled across the country as a result from QMS performing its post closing "+
		"quality assurance reviews.  NMA can determine if adverse appraisal findings were identified as a result of a post closing review and analyze the "+
		"trends by an appraiser arming NMA with the ability to select appraisers that will provide industry standard appraisals.</p>"+
 
		"<p>Appraisal companies and vendors do not have this type of ability unless they purchase data where appraisers have been reported to the state, "+
		"agency, or organization for discipline. NMA offers appraiser trend analysis as a value to it final product and can determine how many high risk loans "+
		"an appraiser is associated.  High risk loans do not always lead to criminal action but high risk loans may lead the lender to financial instability.</p>"+
 
 
		"<br/><br/><font size='4'><b>MARS II Analysis Review Software</b>&#160;&#160;<a href=http://www.qcmortgage.com/mars.html>www.qcmortgage.com/mars.html</a></font> "+
		"<p>This is the same software that Quality Mortgage Services uses as its proprietary software. It "+
		"requires critical thinking and analytical process of loans (it is not a check list solution) "+
		"<ul><li>Re-verification Letters with bar coding </li>"+
		"<li>Date stamp when verification are received and sent</li>"+
		"<li>Date stamp when comments and other data entries are made</li>"+
		"<li>We provide corporate branding setup</li>"+
		"<li>We provide configurations free that are within reason</li>"+
		"<li>Summary Report with basic results of the report</li>"+
		"<li>Loan summary with each borrower</li>"+
		"<li>Finding and Comment information for each report</li>"+
		"<li>Portal access to run compare and contrast reports i.e., November 06, December 06, with November 07, December 07</li>"+
		"<li>Management Responses  Area in the portal where responses and actions taken to findings can be annotated</li>"+
		"<li>Management Report  The reports that combines the QC Report and Management Responses in one report that can be provided to board members, examiners, auditors, agencies, or investors</li>"+
		"<li>Continuous enhancements are being made to meet the needs of the end users with no charge</li></ul></p>";
 
            mail_subj = "ATTN: QMS Order " + clientabbr + " (R-" + id_orderheader + ")";
        }
        else if (type == REPORT)
        {
             mail_body = "<p style='font-family:times; font-size:12pt'><br><b>Quality Mortgage Services</b> has completed Quality Assurance Review "+
		"of your latest order and the report is now available.  If you have problems accessing this report, or have questions, you may "+
		"contact <a href=http://www.qcmortgage.com>QMS</a> at (615) 591-2528, or send an email to orders@qcmortgage.com. <br><br>" +
		"The following link directs you to the <a href=http://www.qualitymortgageservices.com>Quality " +
		"Mortgage Services</a> portal where you can login to access resources pertaining to your compliance review. The portal has a " +
		"registration link in order to register for your user name and password. After you register, contact <a href=http://www.qcmortgage.com>QMS</a>"+
		" to activate your account. Use the portal as a management tool to run various reports.  Click the link below to access the portal.<br><br>";
 
            mail_link = "<a href=https://qcmortgage.com/portal/login.aspx>https://qcmortgage.com/portal</a><br><br>If you have any questions with " +
			"your account contact <a href=http://www.qcmortgage.com>QMS</a> at (615) 591-2528 x25.<br><br><font color='#FF0000'><b>NOTE:</b>"+
			"<font color='#000000'> Your account will not be activated until your information is validated by our staff. <br><br><br>Comments: " +
			txtComments.Text + "</p>" +
 
			"<b><h1><center><font color='#AF7817'>FREE COMPLIANCE!</font></center></h1><font size='4'>Qdocs.net</b>&#160;&#160;<a href=http://www.qdocs.net>www.qdocs.net </a></font>" +
		"<p>Qdocs.net and Quality Mortgage Services has put together a way for the mortgage professional to receive post-closing mortgage compliance free. " +
		"This is what you get with Qdocs.net and Quality Mortgage Services: <br/>" +
		"<ul><li>A secure facility to keep closed loans and paper palletized and shrink wrapped </li>" +
		"<li>Secure data center and secure FTP uploads</li>"+
		"<li>Disaster Recover Plan for data kept out of state </li>" +
		"<li>Your borrower will have access to his/her closing documents and appraisal</li>"+
		"<li>When your borrower accesses his/her file, you will receive an E-mail notification </li>"+
		"<li>You will have secure web portal access to all files</li>"+
		"<li>All files can be printed or exported but never altered</li>"+
		"<li>You will receive free mortgage compliance</li><br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of closed loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of denied/withdrawn FHA loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 100% Early Payment Defaults(EPDs)<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; Field Review Appraisals free<br/></ul></p>"+
 
		"<br/><font size='4'><b>National Mortgage Appraisers</b>&#160;&#160;<a href=http://www.nationalmortgageappraisers.com>www.nationalmortgageappraisers.com </a></font>"+
		"<p>A database of appraisers associated with high risk loans "+
		"Brokers & Bankers will no longer be able to order appraisals directly from the appraisers. "+
		"How many compliance companies you know own an appraiser company that tracks high risk appraisals?</p>"+
 
		"<p>Quality Mortgage Services provides data from MARS II, Mortgage Analyst Software, so that National Mortgage Appraisers can verify appraisers "+
		"are not associated with fraudulent or high risk loans.  This data is compiled across the country as a result from QMS performing its post closing "+
		"quality assurance reviews.  NMA can determine if adverse appraisal findings were identified as a result of a post closing review and analyze the "+
		"trends by an appraiser arming NMA with the ability to select appraisers that will provide industry standard appraisals.</p>"+
 
		"<p>Appraisal companies and vendors do not have this type of ability unless they purchase data where appraisers have been reported to the state, "+
		"agency, or organization for discipline. NMA offers appraiser trend analysis as a value to it final product and can determine how many high risk loans "+
		"an appraiser is associated.  High risk loans do not always lead to criminal action but high risk loans may lead the lender to financial instability.</p>"+
 
 
		"<br/><br/><font size='4'><b>MARS II Analysis Review Software</b>&#160;&#160;<a href=http://www.qcmortgage.com/mars.html>www.qcmortgage.com/mars.html</a></font> "+
		"<p>This is the same software that Quality Mortgage Services uses as its proprietary software. It "+
		"requires critical thinking and analytical process of loans (it is not a check list solution) "+
		"<ul><li>Re-verification Letters with bar coding </li>"+
		"<li>Date stamp when verification are received and sent</li>"+
		"<li>Date stamp when comments and other data entries are made</li>"+
		"<li>We provide corporate branding setup</li>"+
		"<li>We provide configurations free that are within reason</li>"+
		"<li>Summary Report with basic results of the report</li>"+
		"<li>Loan summary with each borrower</li>"+
		"<li>Finding and Comment information for each report</li>"+
		"<li>Portal access to run compare and contrast reports i.e., November 06, December 06, with November 07, December 07</li>"+
		"<li>Management Responses  Area in the portal where responses and actions taken to findings can be annotated</li>"+
		"<li>Management Report  The reports that combines the QC Report and Management Responses in one report that can be provided to board members, examiners, auditors, agencies, or investors</li>"+
		"<li>Continuous enhancements are being made to meet the needs of the end users with no charge</li></ul></p>";
 
            mail_subj = "ATTN:  Your Quality Control Report (R-" + id_orderheader + ")";
        }
        else if (type == INVOICE)
        {
               mail_body = "<p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has completed your latest order " +
                	"of files for Quality Assurance review and the invoice is now ready.  If you have problems accessing this invoice, or have questions, " +
               	 	"you may contact <a href=http://www.qcmortgage.com>QMS</a> at (615) 591-2528, or send an email to orders@qcmortgage.com. <br><br>"+
		"The following link directs you to the <a href=http://www.qualitymortgageservices.com>Quality " +
		"Mortgage Services</a> portal where you can login to access resources pertaining to your compliance review. The portal has a " +
		"registration link in order to register for your user name and password. After you register, contact <a href=http://www.qcmortgage.com>QMS</a>"+
		" to activate your account. Use the portal as a management tool to run various reports.  Click the link below to access the portal.<br><br>";
 
            mail_link = "<a href=https://qcmortgage.com/portal/login.aspx>https://qcmortgage.com/portal</a><br><br>If you have any questions with " +
			"your account contact <a href=http://www.qcmortgage.com>QMS</a> at (615) 591-2528 x25.<br><br><font color='#FF0000'><b>NOTE:</b>"+
			"<font color='#000000'> Your account will not be activated until your information is validated by our staff. <br><br><br>Comments: " + 
			txtComments.Text + "</p>" +
 
		"<b><h1><center><font color='#AF7817'>FREE COMPLIANCE!</font></center></h1><font size='4'>Qdocs.net</b>&#160;&#160;<a href=http://www.qdocs.net>www.qdocs.net </a></font>" +
		"<p>Qdocs.net and Quality Mortgage Services has put together a way for the mortgage professional to receive post-closing mortgage compliance free. " +
		"This is what you get with Qdocs.net and Quality Mortgage Services: <br/>" +
		"<ul><li>A secure facility to keep closed loans and paper palletized and shrink wrapped </li>" +
		"<li>Secure data center and secure FTP uploads</li>"+
		"<li>Disaster Recover Plan for data kept out of state </li>" +
		"<li>Your borrower will have access to his/her closing documents and appraisal</li>"+
		"<li>When your borrower accesses his/her file, you will receive an E-mail notification </li>"+
		"<li>You will have secure web portal access to all files</li>"+
		"<li>All files can be printed or exported but never altered</li>"+
		"<li>You will receive free mortgage compliance</li><br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of closed loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 10% sampling of denied/withdrawn FHA loans<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; 100% Early Payment Defaults(EPDs)<br/>"+
		"&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#9830; Field Review Appraisals free<br/></ul></p>"+
 
		"<br/><font size='4'><b>National Mortgage Appraisers</b>&#160;&#160;<a href=http://www.nationalmortgageappraisers.com>www.nationalmortgageappraisers.com </a></font>"+
		"<p>A database of appraisers associated with high risk loans "+
		"Brokers & Bankers will no longer be able to order appraisals directly from the appraisers. "+
		"How many compliance companies you know own an appraiser company that tracks high risk appraisals?</p>"+
 
		"<p>Quality Mortgage Services provides data from MARS II, Mortgage Analyst Software, so that National Mortgage Appraisers can verify appraisers "+
		"are not associated with fraudulent or high risk loans.  This data is compiled across the country as a result from QMS performing its post closing "+
		"quality assurance reviews.  NMA can determine if adverse appraisal findings were identified as a result of a post closing review and analyze the "+
		"trends by an appraiser arming NMA with the ability to select appraisers that will provide industry standard appraisals.</p>"+
 
		"<p>Appraisal companies and vendors do not have this type of ability unless they purchase data where appraisers have been reported to the state, "+
		"agency, or organization for discipline. NMA offers appraiser trend analysis as a value to it final product and can determine how many high risk loans "+
		"an appraiser is associated.  High risk loans do not always lead to criminal action but high risk loans may lead the lender to financial instability.</p>"+
 
 
		"<br/><br/><font size='4'><b>MARS II Analysis Review Software</b>&#160;&#160;<a href=http://www.qcmortgage.com/mars.html>www.qcmortgage.com/mars.html</a></font> "+
		"<p>This is the same software that Quality Mortgage Services uses as its proprietary software. It "+
		"requires critical thinking and analytical process of loans (it is not a check list solution) "+
		"<ul><li>Re-verification Letters with bar coding </li>"+
		"<li>Date stamp when verification are received and sent</li>"+
		"<li>Date stamp when comments and other data entries are made</li>"+
		"<li>We provide corporate branding setup</li>"+
		"<li>We provide configurations free that are within reason</li>"+
		"<li>Summary Report with basic results of the report</li>"+
		"<li>Loan summary with each borrower</li>"+
		"<li>Finding and Comment information for each report</li>"+
		"<li>Portal access to run compare and contrast reports i.e., November 06, December 06, with November 07, December 07</li>"+
		"<li>Management Responses  Area in the portal where responses and actions taken to findings can be annotated</li>"+
		"<li>Management Report  The reports that combines the QC Report and Management Responses in one report that can be provided to board members, examiners, auditors, agencies, or investors</li>"+
		"<li>Continuous enhancements are being made to meet the needs of the end users with no charge</li></ul></p>";
 
            mail_subj = "ATTN:  Your QMS Invoice (R-" + id_orderheader + ")";
        }
 
 
 
        MailMessage mail = new MailMessage();
        mail.From = "orders@qcmortgage.com";
        mail.Subject = mail_subj;
        mail.BodyFormat = MailFormat.Html;
        mail.Body = mail_body + mail_link;
        mail.To = email_recipients;
        mail.Cc = "orders@qcmortgage.com"; 
       if (type == REPORT || type == INVOICE)
            mail.Cc += "; tduncan@qcmortgage.com";
        mail.Bcc = "tech@qcmortgage.com";
       // objattach = new MailAttachment(Attach1);
        String strFileName = "";
        String strFileName2 = "";
        String strFileName3 = "";
        String attach1 = "";
        String attach2a = "";
        String attach3a = "";
 
 
        HttpPostedFile attFile = FileUpload1.PostedFile;
        strFileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
        if (!strFileName.Equals(""))
        {
            FileUpload1.PostedFile.SaveAs(Server.MapPath(strFileName));
 
            MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
            mail.Attachments.Add(attach);
            attach1 = strFileName;
        }
 
 
        /* if (FileUpload2.PostedFile != null)
         {
             HttpPostedFile attFile2 = FileUpload2.PostedFile;
             strFileName2 = Path.GetFileName(FileUpload2.PostedFile.FileName);
             FileUpload2.PostedFile.SaveAs(Server.MapPath(strFileName2));
             MailAttachment attach2 = new MailAttachment(Server.MapPath(strFileName2));
             mail.Attachments.Add(attach2);
             attach2a = strFileName2;
         }
         if (FileUpload3.PostedFile != null)
         {
             HttpPostedFile attFile3 = FileUpload3.PostedFile;
             strFileName3 = Path.GetFileName(FileUpload3.PostedFile.FileName);
             FileUpload3.PostedFile.SaveAs(Server.MapPath(strFileName3));
             MailAttachment attach3 = new MailAttachment(Server.MapPath(strFileName3));
             mail.Attachments.Add(attach3);
             attach3a = strFileName3;
         }           */
 
        SmtpMail.SmtpServer = "mail.qcmortgage.com";
        try
        {
            SmtpMail.Send(mail);
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message + "<br> Please wait a few moments or contact the System Admin for support.";
        }
 
 
        if (!strFileName.Equals(""))
        {
            if (attach1 != null)
                File.Delete(Server.MapPath(attach1));
            /*if (attach2a != null)
                File.Delete(Server.MapPath(attach2a));
            if (attach3a != null)
                File.Delete(Server.MapPath(attach3a));*/
        }
        Response.Redirect("emailsent.aspx");
    }
 
    private String getAuthorizationIfExists(String orderheader_id, String auth_purpose)
    {
        String auth_number = null;
        String sql = "select auth_number from qc_order_auth where orderheader_id = @order " +
            "and auth_purpose = @purpose";
        try
        {
            String connStr = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@order", orderheader_id);
                    cmd.Parameters.AddWithValue("@purpose", auth_purpose);
                    using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        if (rdr.Read() && !rdr.IsDBNull(0))
                            auth_number = rdr.GetString(0);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            // lblMsg.Text = ex.Message + "<br>" + ex.Source;
            throw ex;
        }
 
        return auth_number;
    }
 
    private String randomizeSessionId()
    {
        String str1 = "";
 
        String sid = Session.SessionID;
        char[] c = sid.ToCharArray();
        int len = sid.Length;
 
        Random r = new Random();
        int r1 = r.Next(len);
        int r2 = r1;
        while (r1 == r2)
            r2 = r.Next(len);
        int r3 = r.Next(len);
 
        char c1 = c[r1];
        char c2 = c[r2];
        c[r1] = c2;
        c[r2] = c1;
 
        for (int i = 0; i < c.Length; i++)
            str1 += c[i].ToString();
        String tmp = r.Next(11111, 99999).ToString();
        str1 = str1.Insert(r3, tmp);
        return str1;
    }
 
    protected void btnEmail_Click(object sender, EventArgs e)
    {
 
 
        String id_orderheader = Request.QueryString["id"].ToString();
        String sid = randomizeSessionId();
        bool isAlreadyAuthorized = true;
        String auth_number = getAuthorizationIfExists(id_orderheader, "ORDER");
 
        if (auth_number == null)
            isAlreadyAuthorized = false;
        else
            sid = auth_number;
 
        if (!isAlreadyAuthorized)
            setAuthorization(id_orderheader, sid, "ORDER");
        sendEmail(id_orderheader, sid, ORDER);
 
    }
    protected void btnAddAttachment_Click(object sender, EventArgs e)
    {
        if (lblAttachment1.Text == "")
        {
            lblAttachment1.Text = FileUpload1.PostedFile.FileName.ToString();
        }
        else if (lblAttachment1.Text != "" && lblAttachment2.Text == "")
        {
            lblAttachment2.Text = FileUpload1.PostedFile.FileName.ToString();
        }
        else if (lblAttachment1.Text != "" && lblAttachment2.Text != "")
        {
            lblAttachment3.Text = FileUpload1.PostedFile.FileName.ToString();
}    
    if (lblAttachment1.Text != "" && lblAttachment2.Text != "" && lblAttachment3.Text != "")
            lblMsg.Text = "Cannot add any more attachments";
        
        
        
         
         
         
    }
}

Open in new window

0
brucegust
Asked:
brucegust
  • 2
1 Solution
 
MrAgileCommented:
Hi There,

One possible solution is to put the content into an xml file. Break the html up so that the references to all images are from the server itself and then using stringbuilder append all of the information to the html of the email. The solution that you have here now is way too hard to maintain.

Let me know if you would like any further clarification.

Sean
0
 
Sachintana DissanayakeSenior Web DeveloperCommented:
Just add a label control to the page and set the Text property as below. It;s good to add a label inside a div, panel or frame to bound into proper margins.
   label1.Text = mail_body + mail_link;
0
 
brucegustAuthor Commented:
Here's what I want to do based on the limited skillset that the kid currently possesses...

Here's the code as it exists right now:


 if (type == ORDER)
 {
 mail_body = "<p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has now completed your " +
"latest order of files chosen for Quality Assurance review. " +
  "If you have problems accessing the order, have questions about this order, or loan substitutions are needed, " +
  "you may contact <a href=http://www.qcmortgage.com>QMS</a> at 615-591-2528, or send an email to orders@qcmortgage.com.  By clicking " +
  "on the following link, you can access this order: <br>&nbsp;<br>";

mail_link = "<a href=https://qcmortgage.com/mars2/qcorder.aspx?sid=" + session_id + ">https://qcmortgage.com/mars2/qcorder.aspx?sid=" +
 session_id + "</a> <br><br>&nbsp;<br>" +
"Comments: " + txtComments.Text + "</p><br/><br/>" +

"<font size='4'>Qdocs.net</b>&#160;&#160;<a href=http://www.qdocs.net>www.qdocs.net </a></font>" +
<br/><font size='4'><b>National Mortgage Appraisers</b>&#160;&#160;<a href=http://www.nationalmortgageappraisers.com>www.nationalmortgageappraisers.com </a></font>"+
"<br/><font size='4'><b>MARS II Analysis Review Software</b>&#160;&#160;<a href=http://www.qcmortgage.com/mars.html>www.qcmortgage.com/mars.html</a></font>";

mail_subj = "ATTN: QMS Order " + clientabbr + " (R-" + id_orderheader + ")";
}

The email script looks like this:

 MailMessage mail = new MailMessage();
        mail.From = "orders@qcmortgage.com";
        mail.Subject = mail_subj;
        mail.BodyFormat = MailFormat.Html;
        mail.Body = mail_body + mail_link;
        mail.To = email_recipients;
        mail.Cc = "orders@qcmortgage.com";
       if (type == REPORT || type == INVOICE)
            mail.Cc += "; tduncan@qcmortgage.com";
        mail.Bcc = "tech@qcmortgage.com";

All I want to do is change the " mail.Body = mail_body + mail_link;" part and make it where "mail_body" includes my HTML formatting with the "mail_link" embedded within. The end result would something like what I have below:

Now, my problem is that I don't recognize the syntax that's being used as far as the links, for example. In the code below, unlike HTML, the link is not in quotes. Consider

"<a href=https://qcmortgage.com/mars2/qcorder.aspx?sid=" + session_id + ">https://qcmortgage.com/mars2/qcorder.aspx?sid=" +
 session_id + "</a> <br><br>&nbsp;<br>" +
"Comments: " + txtComments.Text + "</p><br/><br/>" +

What kind of language is that and how do I reference an image using that kind of approach? If I have a header that's <IMG SRC="http://www.brucegust.com/Header.jpg">, would the code be "<IMG SRC=http://www.brucegust.com/Header.jpg>"

And then I don't understand the "+ dynamic. I'm assuming that's the way you conjucate the code (I'm not sure I have the spelled correctly).

Those are my two biggest questions. I think I can figure it out from there if I can just get my arms around how to incorporate the HTML in a way that's consistent with whatever language is being used to produce the verbiage and links the way they exist in the current page.

Help..?
<table width=600 align="center">
<tr>
<td>
<!- here's the code coming from the existing format ->
 
"<p style='font-family:times; font-size:12pt'><b>Quality Mortgage Services</b> has now completed your " +
"latest order of files chosen for Quality Assurance review. " +
  "If you have problems accessing the order, have questions about this order, or loan substitutions are needed, " +
  "you may contact <a href=http://www.qcmortgage.com>QMS</a> at 615-591-2528, or send an email to orders@qcmortgage.com.  By clicking " +
  "on the following link, you can access this order: <br>&nbsp;<br>";
 
"<a href=https://qcmortgage.com/mars2/qcorder.aspx?sid=" + session_id + ">https://qcmortgage.com/mars2/qcorder.aspx?sid=" +
 session_id + "</a> <br><br>&nbsp;<br>" +
"Comments: " + txtComments.Text + "</p><br/><br/>" + 
 
 
</td>
</tr>
</table>

Open in new window

0
 
Sachintana DissanayakeSenior Web DeveloperCommented:
You can get double quotes (") for html links in your email as follows,
   "you may contact <a href=\"http://www.qcmortgage.com\">QMS</a> ... using \ before the " symbol.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now