Inheritance: IMarkupConverter
Ejemplo n.º 1
0
        void GetRTF()
        {
            MarkupConverter.MarkupConverter markupConverter = new MarkupConverter.MarkupConverter();
            StringBuilder html = new StringBuilder("<Table>");
            string        temp;

            foreach (SelectTextosPrimaPresentacion_Result texto in obs)
            {
                html.Append("<tr><td><b>");
                if (string.IsNullOrEmpty(texto.texto1))
                {
                    html.Append("&nbsp;");
                }
                else
                {
                    html.Append(texto.texto1);
                }

                html.Append("</b></td><td>");

                if (string.IsNullOrEmpty(texto.texto2))
                {
                    html.Append("&nbsp;");
                }
                else
                if (texto.texto2.Contains("<br>"))
                {
                    foreach (string valor in texto.texto2.Split(new string[] { "<br>" }, StringSplitOptions.None))
                    {
                        temp = valor.StartsWith("&nbsp;") ? "." + valor: valor;
                        html.Append(temp);
                        html.Append("</td></tr><tr><td><b>&nbsp;</b></td><td>");
                    }
                }
                else
                {
                    html.Append(texto.texto2);
                }

                html.Append("</td></tr>");
            }
            html.Append("</table>");

            rtf = markupConverter.ConvertHtmlToRtf(html.ToString());

            rtf = rtf.Replace("cellx1440", "cellx3502").Replace("cellx2880", "cellx11136").Replace(@"clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\", "");
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs evnt) //gönderme işlemi
 {
     if (textBox1.Text != "" && textBox2.Text != "")
     {
         metinbaslangicIndex = 0;
         SmtpClient  client  = new SmtpClient();
         MimeMessage message = new MimeMessage();
         BodyBuilder builder = new BodyBuilder();
         client.ServerCertificateValidationCallback = (s, c, h, e) => true;
         client.Connect("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
         client.Authenticate(login_user.Instance.Eposta, login_user.Instance.sifre);
         bool hata_varmı = false;
         bool loop       = true;
         rtf = richTextBox1.Rtf;
         while (loop)
         {
             try
             {
                 tut = ExtractImgRtf(rtf);
             }
             catch (Exception)
             {
                 hata_varmı = true;
             }
             try
             {
                 bool             duplicate_engelleme = false;
                 IMarkupConverter markupConverter     = new MarkupConverter.MarkupConverter();
                 if (hata_varmı == false)
                 {
                     for (int i = 0; i < bfile.Count; i++)
                     {
                         if (bfile[i].bodyfile_string == tut && duplicate_engelleme == false)
                         {
                             duplicate_engelleme = true;
                             string body = rtf.Substring(metinbaslangicIndex, startIndex - metinbaslangicIndex);
                             metinbaslangicIndex = (endIndex + 12);
                             var bodyfile = builder.LinkedResources.Add(bfile[i].file_name, bfile[i].bodyfile_byte);
                             bodyfile.ContentId = MimeUtils.GenerateMessageId();
                             //try catch gelcek ve text html yerine textx döncek if error
                             string html_body = markupConverter.ConvertRtfToHtml(body);
                             builder.HtmlBody += html_body;
                             builder.HtmlBody += string.Format(@"<img src=""cid:{0}"" width={1} height={2} > ", bodyfile.ContentId, width, height);
                         }
                     }
                     duplicate_engelleme = false;
                 }
                 else
                 {
                     string body      = rtf.Substring(metinbaslangicIndex, richTextBox1.Rtf.Length - metinbaslangicIndex);
                     string html_body = markupConverter.ConvertRtfToHtml(body);
                     builder.HtmlBody += html_body;
                     loop              = false;
                 }
             }
             catch (Exception ht)
             {
                 MessageBox.Show("Hata: " + ht);
                 string body = richTextBox1.Text;
                 builder.TextBody = body;
                 loop             = false;
             }
         }
         bool empty = !attachment_dondur.Any();
         if (empty != true)
         {
             foreach (string yol in attachment_dondur)
             {
                 builder.Attachments.Add(@"" + yol);
             }
         }
         bool mesaj_gittimi = true;
         try
         {
             message.From.Add(MailboxAddress.Parse(login_user.Instance.Eposta));
             message.To.Add(MailboxAddress.Parse(textBox1.Text));
             message.Subject = textBox2.Text;
             message.Body    = builder.ToMessageBody();
             client.Send(message);
         }
         catch (Exception ht)
         {
             MessageBox.Show("Mail yollanırken hata ile karşılaşıldı: " + ht);
             mesaj_gittimi = false;
         }
         finally
         {
             startIndex          = 0;
             endIndex            = 0;
             metinbaslangicIndex = 0;
             bfile.Clear();
             richTextBox1.Clear();
         }
         if (mesaj_gittimi == true)
         {
             MessageBox.Show("Mesaj Gönderildi.");
         }
     }
     else
     {
         if (textBox1.Text == "")
         {
             textBox1.Text = "Gönderilecek kişi ksmı boş geçilemez.";
         }
         if (textBox2.Text == "")
         {
             textBox2.Text = "Konu ksmı boş geçilemez.";
         }
         MessageBox.Show("Lütfen Her bir bölümü doldurduğunuza emin olunuz...");
     }
 }