Exemplo n.º 1
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     TextBox1.Enabled      = true;
     TextBox2.Enabled      = true;
     TextBox3.Enabled      = true;
     TextBox4.Enabled      = true;
     TextBox5.Enabled      = true;
     CheckBoxList2.Enabled = true;
     CheckBoxList3.Enabled = true;
     CheckBoxList4.Enabled = true;
     CheckBoxList1.Enabled = true;
     Label1.Text           = null;
     TextBox1.Text         = null;
     TextBox2.Text         = null;
     TextBox3.Text         = null;
     TextBox4.Text         = null;
     TextBox5.Text         = null;
     CheckBoxList2.ClearSelection();
     CheckBoxList3.ClearSelection();
     CheckBoxList4.ClearSelection();
     CheckBoxList1.ClearSelection();
 }
Exemplo n.º 2
0
    /*void saveToPdf(string base64Str, string filePath, string file)
     * {
     *  byte[] bytes = Convert.FromBase64String(base64Str);
     *  //string filename = file + ".pdf";
     *  //string filename = CheckBoxList1.SelectedItem.ToString();
     *  //string filepath = CheckBoxList1.SelectedValue;
     *
     *  //System.IO.FileStream stream = new FileStream(filePath + filename, FileMode.CreateNew);
     * // System.IO.BinaryWriter writer = new BinaryWriter(stream);
     *  //writer.Write(bytes, 0, bytes.Length);
     *  //writer.Close();
     * }*/

    #region Send Message New Business/ Cover Note
    //send message button for new business
    protected void Button7_Click(object sender, EventArgs e)
    {
        MemoryStream ms1 = new MemoryStream();

        try
        {
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("*****@*****.**", "Coverinaclick.ie", System.Text.Encoding.UTF8);
            msg.To.Add(to_email.Text);
            msg.Subject         = subject.Text;
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            //msg.Body = message_area.Value;
            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml   = true;
            var application = new Microsoft.Office.Interop.Word.Application();
            var document    = new Microsoft.Office.Interop.Word.Document();


            document = application.Documents.Add(Template: @"c:\Projects\CoverNote.docx");
            //application.Visible = true;

            foreach (Microsoft.Office.Interop.Word.Field field in document.Fields)
            {
                if (field.Code.Text.Contains("FirstName"))
                {
                    field.Select();
                    application.Selection.TypeText(fullname_txtbox.Text);
                }
                else if (field.Code.Text.Contains("date"))
                {
                    field.Select();
                    application.Selection.TypeText(TextBox2.Text);
                }
                else if (field.Code.Text.Contains("InsuranceCoy"))
                {
                    field.Select();
                    application.Selection.TypeText("Axa");
                }
                else if (field.Code.Text.Contains("benefits"))
                {
                    field.Select();
                    List <String> CheckBoxListStr1 = new List <string>();
                    foreach (ListItem item1 in CheckBoxList3.Items)
                    {
                        if (item1.Selected)
                        {
                            CheckBoxListStr1.Add(item1.Value);
                        }
                    }

                    String checkList1 = String.Join(" ", CheckBoxListStr1.ToArray());
                    application.Selection.TypeText(checkList1);
                }
                else if (field.Code.Text.Contains("docs"))
                {
                    field.Select();
                    List <String> CheckBoxListStr = new List <string>();
                    foreach (ListItem item in CheckBoxList2.Items)
                    {
                        if (item.Selected)
                        {
                            CheckBoxListStr.Add(item.Value);
                        }
                    }

                    String checkList = String.Join(Environment.NewLine, CheckBoxListStr.ToArray());
                    application.Selection.TypeText(checkList);
                }
            }
            DateTime add_Months = Convert.ToDateTime(TextBox2.Text).AddDays(365);
            TextBox3.Text = add_Months.ToString();

            var x = double.Parse(gross_amt.Text);
            var y = double.Parse(chrg.Text);
            var z = x + y;

            List <String> checkbxlst = new List <string>();
            foreach (ListItem item in CheckBoxList3.Items)
            {
                if (item.Selected)
                {
                    checkbxlst.Add(item.Value);
                }
            }
            string theList = String.Join(",", checkbxlst.ToArray());

            List <String> checkbxlst1 = new List <string>();
            foreach (ListItem item in CheckBoxList2.Items)
            {
                if (item.Selected)
                {
                    checkbxlst1.Add(item.Value);
                }
            }
            string theList1 = String.Join(",", checkbxlst1.ToArray());

            //msg.Body = document.Content.Text;
            msg.Body = "<p>Dear " + fullname_txtbox.Text + ", </p>" + "<p> Thank you for your new business instruction, we have incepted cover from " + TextBox2.Text + ". </p>" +
                       "\n" + "<p> Find attached proposal form/statement of fact, which contains the information on which we have provided the quotation and incepted cover. Ensure that you read the proposal form/statement of fact to ensure all risk details are correct. If any of the details are not accurate to the acceptance and assessment of the risk, then please provide full details immediately. </p>"
                       + "<p> Your policy would include: </p>" + "&#8594 " + theList
                       + "<p> The proposal form/statement of fact will form part of the contract between you and your insurance company. </p>"
                       + "<p> Please forward the following documents within 7 days:  </p>" + "&#8594" + theList1
                       + "\n" + "<p>Thank you </p>" + "\n----------------" + "<br />" + "coverinaclick.ie"
                       + "<br />Insurance House"
                       + "<br />" + "62A Terenure Road North"
                       + "<br />" + "Terenure"
                       + "<br />" + "Dublin 6W"
                       + "<p><a href = www.insuremyvan.ie><img src = imv.jpg alt = IMV_LOGO></a>"
                       + "<a href = www.coverinaclick.ie><img src = ciac.jpg alt = CIAC_LOGO></a>"
                       + "<a href = www.insuremyhouse.ie><img src = imh.jpg alt = IMH_LOGO></a></p>"

                       /*+ "<p> --------------------------------------------------------------------------------------------"
                        + "<br />" + "-------------------------------------------------------------------------------------------"
                        + "<br />" + " &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp<strong> INVOICE </strong>"
                        + "<br />" + "Should you wish to make any further alterations to your policy, please advise us, and any adjustments will be dealt with when completed."
                        + "\n" + "<table border = 1 style = width:100%> <tr> <td> Period of cover: &nbsp &nbsp &nbsp" + TextBox2.Text + " " + "to" + " " + TextBox3.Text
                        + "<p> Premium:  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp" + "€" + gross_amt.Text + "</p>"
                        + "<p>Administration charge: &nbsp &nbsp &nbsp &nbsp  " + "€" + chrg.Text + "</p>"
                        + "<p><strong> TOTAL PREMIUM: &nbsp &nbsp &nbsp &nbsp </strong>" + "€" + z + "</p></td></tr></table>"*/
                       + "<p><strong> SPECIAL NOTICE - DUTY OF DISCLOSURE</strong> </P>"
                       + "\n" + "<ol>" + "<li> Duty of Disclosure: Any facts known to you, and any changes affecting the risk since inception of the policy or last renewal date (whichever is the later) must be disclosed to us. Failure to disclose may mean that your policy may not provide you with the cover you require, or may invalidate the policy altogether.</li>"
                       + "<li> The amount shown includes a 5% Government levy and an Administration Charge (1989 Insurance Act of Practice)</li>" + "</ol>"
                       + "<p><font color = blue> City Financial Marketing Group Ltd is regulated by the Central Bank of Ireland</p>"
                       + "<p>City Financial Marketing is a memeber of the Irish Brokers Association</p>"
                       + "<p>City Financial Marketing Group Ltd is a company registered in Ireland. Registered office is situated at 70 Northumberland Road, Ballsbridge, Dublin 4, Registered Number 235088.</p>"
                       + "<p>This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the CFM Group. Finally, whilst every effort has been made to ensure this e-mail and any attachments are virus free CFM Group Ltd accepts no liability for any damage caused should any viruses be transmitted by this email.</p>"
                       + "\nPlease consider the environment before printing this email.</font>";



            using (System.IO.MemoryStream ms = new MemoryStream())
            {
                using (System.IO.StreamWriter writer = new StreamWriter(ms))
                {
                    writer.Write("Hello");
                    writer.Flush();
                    //writer.Dispose();

                    System.Net.Mime.ContentType ct        = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
                    System.Net.Mail.Attachment  attchFile = new Attachment(ms, ct);
                    //attchFile.ContentStream.
                    attchFile.ContentDisposition.FileName = "Terms of Business.pdf";
                    msg.Attachments.Add(attchFile);
                    if (FileUpload3.HasFile)
                    {
                        Attachment attachment;
                        attachment = (new Attachment(FileUpload3.PostedFile.InputStream, FileUpload3.FileName));
                        attachment.ContentDisposition.FileName = "Your Policy Booklet.pdf";
                        msg.Attachments.Add(attachment);
                    }
                    if (FileUpload4.HasFile)
                    {
                        Attachment attachment1;
                        attachment1 = (new Attachment(FileUpload4.PostedFile.InputStream, FileUpload4.FileName));
                        attachment1.ContentDisposition.FileName = "Proposal Form " + "/" + "Statement of Fact.pdf";
                        msg.Attachments.Add(attachment1);
                    }
                    if (FileUpload5.HasFile)
                    {
                        //Directory.CreateDirectory(@"");
                        Attachment attachment2;
                        attachment2 = (new Attachment(FileUpload5.PostedFile.InputStream, FileUpload5.FileName));
                        attachment2.ContentDisposition.FileName = "Direct Debit Mandate.pdf";
                        msg.Attachments.Add(attachment2);
                    }
                    if (FileUpload6.HasFile)
                    {
                        //Directory.CreateDirectory(@"");
                        Attachment attachment3;
                        attachment3 = (new Attachment(FileUpload6.PostedFile.InputStream, FileUpload6.FileName));
                        attachment3.ContentDisposition.FileName = "Gap in Cover";
                        msg.Attachments.Add(attachment3);
                    }
                    if (FileUpload7.HasFile)
                    {
                        //Directory.CreateDirectory(@"");
                        Attachment attachment4;
                        attachment4 = (new Attachment(FileUpload7.PostedFile.InputStream, FileUpload7.FileName));
                        attachment4.ContentDisposition.FileName = "Sold Car Declaration";
                        msg.Attachments.Add(attachment4);
                    }
                    if (FileUpload8.HasFile)
                    {
                        //Directory.CreateDirectory(@"");
                        Attachment attachment5;
                        attachment5 = (new Attachment(FileUpload8.PostedFile.InputStream, FileUpload8.FileName));
                        attachment5.ContentDisposition.FileName = "Surrender of NCB";
                        msg.Attachments.Add(attachment5);
                    }
                    msg.IsBodyHtml = true;

                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    System.Net.NetworkCredential netwrkcred = new System.Net.NetworkCredential();
                    netwrkcred.UserName        = "******";
                    netwrkcred.Password        = "******";
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials           = netwrkcred;
                    smtp.Port      = 587;
                    smtp.EnableSsl = true;
                    smtp.Send(msg);

                    //ms.Close();

                    ShowMessage("Message sent!!");

                    CheckBoxList3.ClearSelection();
                    //RadioButtonList1.ClearSelection();
                    to_email.Text = string.Empty;
                    //message_area.Value = string.Empty;
                    TextBox2.Text        = string.Empty;
                    fullname_txtbox.Text = string.Empty;
                    CheckBoxList2.ClearSelection();
                    gross_amt.Text = string.Empty;
                    chrg.Text      = string.Empty;
                }
            }

            //byte[] pdfByte = System.IO.File.ReadAllBytes(Server.MapPath("~/PDF Document/Timetable(1)"));
            //Attachment attachFile = new Attachment(new MemoryStream(CheckBoxList1.DataValueField), "pdf");
            // msg.Attachments.Add(attachFile);
        }
        catch (Exception ex)
        {
            Response.Write("Error" + ex.ToString());
        }
    }