示例#1
0
        static void Main(string[] args)
        {
            string inpFile = @"..\..\example.rtf";
            string outFile = @"Title.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Set document title, <title>...</title>
            r.TextStyle.Title = "Here is the custom TITLE!";

            // Set the folder to store images
            r.ImageStyle.ImageFolder = Path.GetDirectoryName(Path.GetFullPath(outFile));

            try
            {
                r.OpenRtf(inpFile);
                r.ToHtml(outFile);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            // Read our RTF document as string.
            string inpFile    = @"..\..\example.txt";
            string textString = File.ReadAllText(inpFile);

            string outFile = @"Result.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat    = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding        = SautinSoft.RtfToHtml.eEncoding.UTF_8;
            r.TextStyle.Title = "Textual document.";

            try
            {
                r.OpenTextFromString(textString);
                r.ToHtml(outFile);

                // Open the result for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            // Read our DOCX file a bytes array.
            string inpFile = @"..\..\example.docx";

            byte [] rtfBytes = File.ReadAllBytes(inpFile);

            // We'll use the file only for the demonstration.
            string outFile = @"Result.html";

            byte [] htmlBytes = null;

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding     = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            // Imagefolder must already exist.
            r.ImageStyle.ImageFolder = System.Environment.CurrentDirectory;

            // Subfolder for images will be created by the component.
            r.ImageStyle.ImageSubFolder = "image.files";

            // A template name for images.
            r.ImageStyle.ImageFileName = "picture";

            // false - store images as files on HDD,
            // true - store images inside HTML document using base64.
            r.ImageStyle.IncludeImageInHtml = false;

            try
            {
                r.OpenDocx(rtfBytes);

                // Here we've got the HTML document as an array of bytes.
                htmlBytes = r.ToHtml();

                // Save our HTML into file and open it for the demonstration purposes.
                File.WriteAllBytes(outFile, htmlBytes);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            string inpFile          = @"..\..\example.rtf";
            string outFileInlineCSS = @"Inline CSS.html";
            string outFileClassCSS  = @"Class CSS.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Skip images.
            r.ImageStyle.PreserveImages = false;

            try
            {
                r.OpenRtf(inpFile);

                // Specify the title.
                r.TextStyle.Title = "Inline CSS";

                // Generate inline CSS.
                r.TextStyle.InlineCSS = true;

                // Convert to HTML.
                r.ToHtml(outFileInlineCSS);

                // Specify the title.
                r.TextStyle.Title = "Class CSS";

                // Store CSS using the attribute "class".
                r.TextStyle.InlineCSS      = false;
                r.TextStyle.StyleName      = "style";
                r.TextStyle.StartCSSNumber = 100;

                // Convert to HTML.
                r.ToHtml(outFileClassCSS);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileInlineCSS)
                {
                    UseShellExecute = true
                });
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileClassCSS)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            string inpFile = Path.GetFullPath(@"..\..\example.rtf");
            string outFileOriginalFonts = @"Original Fonts.html";
            string outFileSingleFont    = @"Single Font.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Skip images.
            r.ImageStyle.PreserveImages = false;

            try
            {
                r.OpenRtf(inpFile);

                // Specify the title.
                r.TextStyle.Title = "Original Fonts";

                // Convert to HTML.
                r.ToHtml(outFileOriginalFonts);

                // Specify the title.
                r.TextStyle.Title = "Single Font";

                // Set single font family, size and color.
                r.TextStyle.FontColor.SetRGB(6, 85, 53);
                r.TextStyle.FontFace = "Verdana";
                r.TextStyle.FontSize = 18;

                // Convert to HTML.
                r.ToHtml(outFileSingleFont);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileOriginalFonts)
                {
                    UseShellExecute = true
                });
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileSingleFont)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#6
0
        /// <summary>
        /// /
        /// </summary>
        /// <param name="res"></param>
        /// <param name="price"></param>
        /// <param name="payment"></param>
        /// <param name="discount"></param>
        /// <param name="balance"></param>
        /// <param name="FinalAmount"></param>
        /// <returns></returns>
        ///
        public TestResultDto PirntSlip(TestResultDto res, Decimal price, decimal payment, decimal discount, decimal balance, decimal FinalAmount)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);

            string fileName = "" + path + "\\paymentSlip.docx";

            var doc = DocX.Create(fileName);

            decimal dis = price * discount;

            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("        LAB REPORT MANAGEMENT SYSTEM  | FINAL PAYEMENT DETAIL             ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Visit ID         : " + res.VisitID + "                                ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Test Price       Rs : " + price + "   Payment  Rs : " + payment + "   ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Discount         Rs : " + dis + "                                     ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Final Amount  Rs : " + FinalAmount + "                                ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("    Balance Rs     Rs : " + balance + "                                   ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph(" _________________________________________________________________________");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");
            doc.InsertParagraph("                                                                          ");

            doc.Save();

            /*Open as html format*/
            SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml();
            string docxFile        = Path.GetFullPath(fileName);
            string htmlFile        = Path.ChangeExtension(docxFile, ".html");

            z.OpenDocx(docxFile);
            z.ToHtml(htmlFile);
            System.Diagnostics.Process.Start(htmlFile);

            return(null);
        }
示例#7
0
        static void Main(string[] args)
        {
            // Read our RTF document as string.
            string inpFile   = @"..\..\example.rtf";
            string rtfString = File.ReadAllText(inpFile);

            string outFile = @"Result.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding     = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            // Imagefolder must already exist.
            r.ImageStyle.ImageFolder = System.Environment.CurrentDirectory;

            // Subfolder for images will be created by the component.
            r.ImageStyle.ImageSubFolder = "image.files";

            // A template name for images.
            r.ImageStyle.ImageFileName = "picture";

            // false - store images as files on HDD,
            // true - store images inside HTML document using base64.
            r.ImageStyle.IncludeImageInHtml = false;

            try
            {
                r.OpenRtf(rtfString);
                r.ToHtml(outFile);

                // Open the result for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#8
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            bool send = false;

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
            string rtfString       = File.ReadAllText(path_SendRtfFile);

            r.ImageStyle.IncludeImageInHtml = true;
            string text = r.ConvertString(rtfString);
            int    n    = 1;

            foreach (var vari in whomMailList.Items)
            {
                int progressPercentage = Convert.ToInt32(((double)n++ / whomMailList.Items.Count) * 100);
                (sender as BackgroundWorker).ReportProgress(progressPercentage);
                send_mes("Новое письмо", text, filePathList, (string)vari);
                send = true;
            }

            e.Result = send;
        }
示例#9
0
        static void Main(string[] args)
        {
            // We'll use the files only for the demonstration,
            // the whole conversion will be done using MemoryStream.
            string inpFile = @"..\..\example.txt";
            string outFile = @"Result.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat    = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding        = SautinSoft.RtfToHtml.eEncoding.UTF_8;
            r.TextStyle.Title = "Textual document.";

            try
            {
                using (FileStream textFileStream = new FileStream(inpFile, FileMode.Open))
                {
                    r.OpenText(textFileStream);
                    using (MemoryStream htmlMemoryStream = new MemoryStream())
                    {
                        // Here we've got the HTML document as an array of bytes.
                        r.ToHtml(htmlMemoryStream);

                        // Save our HTML into file and open it for the demonstration purposes.
                        File.WriteAllBytes(outFile, htmlMemoryStream.ToArray());
                        System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                        {
                            UseShellExecute = true
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            string inpFile      = @"..\..\unicode.rtf";
            string outFileNCR   = @"NCR.html";
            string outFileNoNCR = @"Without NCR.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            try
            {
                r.OpenRtf(inpFile);

                // Set to use NCR (Numeric Character Reference), in other words
                // write characters as &#XXXX;
                r.UseNumericCharacterReference = true;
                r.TextStyle.Title = "NCR";
                r.ToHtml(outFileNCR);

                // Don't use NCR, write characters us Unicode (utf-8), like a: på taket är en figur.
                r.UseNumericCharacterReference = false;
                r.TextStyle.Title = "Without NCR";
                r.ToHtml(outFileNoNCR);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileNCR)
                {
                    UseShellExecute = true
                });
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileNoNCR)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            // Read our RTF file a bytes array.
            string inpFile = @"..\..\example.txt";

            byte[] textBytes = File.ReadAllBytes(inpFile);

            // We'll use the file only for the demonstration.
            string outFile = @"Result.html";

            byte[] htmlBytes = null;

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            // Specify some properties for output HTML document.
            r.OutputFormat    = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
            r.Encoding        = SautinSoft.RtfToHtml.eEncoding.UTF_8;
            r.TextStyle.Title = "Textual document.";

            try
            {
                r.OpenText(textBytes);

                // Here we've got the HTML document as an array of bytes.
                htmlBytes = r.ToHtml();

                // Save our HTML into file and open it for the demonstration purposes.
                File.WriteAllBytes(outFile, htmlBytes);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#12
0
        static void Main(string[] args)
        {
            string inpFile            = @"..\..\links.rtf";
            string outFileNotDetected = @"detect false.html";
            string outFileDetected    = @"detect true.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            try
            {
                r.OpenRtf(inpFile);

                // Don't detect hyperlinks from text, convert only real hyperlinks.
                r.TextStyle.HyperlinkDetect = false;
                r.TextStyle.Title           = "HyperlinkDetect = false";
                r.ToHtml(outFileNotDetected);

                // Automatically detect hyperlinks from text.
                r.TextStyle.HyperlinkDetect = true;
                r.TextStyle.HyperlinkTarget = SautinSoft.RtfToHtml.eHyperlinkTarget.Blank;
                r.TextStyle.Title           = "HyperlinkDetect = true";
                r.ToHtml(outFileDetected);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileNotDetected)
                {
                    UseShellExecute = true
                });
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileDetected)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            string inpFile       = @"..\..\two paragraphs.rtf";
            string outFileTagP   = @"p.html";
            string outFileTagDiv = @"div.html";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            try
            {
                r.OpenRtf(inpFile);

                // Set tag <p>...</p> for the paragraphs.
                r.TagStyle.ParagraphTag = SautinSoft.RtfToHtml.eTags.p;
                r.TextStyle.Title       = "P tag";
                r.ToHtml(outFileTagP);

                // Set tag <div>...</div> for the paragraphs.
                r.TagStyle.ParagraphTag = SautinSoft.RtfToHtml.eTags.div;
                r.TextStyle.Title       = "DIV tag";
                r.ToHtml(outFileTagDiv);

                // Open the results for demonstration purposes.
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileTagP)
                {
                    UseShellExecute = true
                });
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFileTagDiv)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="printreport"></param>
        /// <returns></returns>
        public TestResultDto PrintReport(TestResultDto printreport)
        {
            MapperConfig.ConfigAutoMapper();



            if (printreport != null)
            {
                int patientid = visit.GetVisit(printreport.VisitID).PatientID;
                var patient   = base.context.Patients.AsNoTracking().FirstOrDefault(p => p.PatientId.Equals(patientid));

                String name    = patient.Name;
                int    age     = patient.Age;
                string sex     = patient.Gender;
                string address = patient.Address;
                string number  = patient.ContactNo;

                DateTime arrivedate = visit.GetVisit(printreport.VisitID).ArriveDate;
                DateTime ExpDelDate = visit.GetVisit(printreport.VisitID).ExpectedDeliveryDate;

                int TesTID       = test.GetTest(printreport.VisitID).TemplateID;
                var testTemplate = base.context.TestTemplates.FirstOrDefault(p => p.TestTemplateId.Equals(TesTID));


                string  templatename = testTemplate.TemplateName;
                int     temID        = testTemplate.TestTemplateId;
                decimal price        = testTemplate.Price;


                IList <TestResultDto>            results = resultSet.GetTestResults(printreport.VisitID);
                IList <TestTemplateAttributeDto> Attribs = VisitHelper.GetTestTemplateAttributes(temID);
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
                string fileName = "" + path + "\\Report.docx";

                var doc = DocX.Create(fileName);

                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("");
                doc.InsertParagraph("                      MEDICAL LAB REPORT MANAGEMENT SYSTEM  |  FINAL TEST REPORT ");
                doc.InsertParagraph("");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Name : " + name + "                                    Gender : " + sex + "                                             ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Age : " + age + "                                                        Address:" + address + "   Payment : RS: " + price + "");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Contact Number : " + number + "                                    Test : " + templatename + "                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("");

                doc.InsertParagraph("     Arrived Date: " + arrivedate + "                      Deliver Date:" + ExpDelDate + "                                           ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");

                doc.InsertParagraph("");
                doc.InsertParagraph("     Patients Results ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int seq = 1;
                foreach (var x in results)
                {
                    doc.InsertParagraph("     " + seq + "           Value: " + x.Value + "              Status : " + x.Status + "");
                    doc.InsertParagraph("");
                    seq++;

                    if (seq > Attribs.Count)
                    {
                        break;
                    }
                }

                doc.InsertParagraph("");
                doc.InsertParagraph("");
                doc.InsertParagraph("    Reffer below Information. ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int NextSeq = 1;
                foreach (var x in Attribs)
                {
                    doc.InsertParagraph("     " + NextSeq + " . " + x.Attribute + " --> " + x.PrefferedLimit + "");
                    doc.InsertParagraph("");
                    doc.InsertParagraph("");
                    NextSeq++;
                }

                doc.Save();

                /*Open as html format*/
                SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml();
                string docxFile        = Path.GetFullPath(fileName);
                string htmlFile        = Path.ChangeExtension(docxFile, ".html");

                z.OpenDocx(docxFile);
                z.ToHtml(htmlFile);
                System.Diagnostics.Process.Start(htmlFile);

                return(null);
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }
        }
示例#15
0
        public void EnvoiMessageAvecPJ(string destinataire, string cc, string message, string objet, string pj, string adresseAMettre)
        {
            try
            {
                //Objet Mail
                msg = new MailMessage();

                // Expéditeur
                msg.From = new MailAddress(this.adresseExpediteur, this.nomExpediteur);

                // Destinataire(s)
                foreach (String dest in destinataire.Split(';'))
                {
                    msg.To.Add(new MailAddress(dest, dest));
                }

                // Destinataire(s) en copie
                if (cc != null && cc != "")
                {
                    foreach (String destcc in cc.Split(';'))
                    {
                        msg.CC.Add(new MailAddress(destcc));
                    }
                }

                //Objet du mail
                msg.Subject = objet;

                //Corps du mail
                //Contenu du mail
                SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
                r.ImageStyle.IncludeImageInHtml = true;
                System.Collections.ArrayList arListWithImages = new System.Collections.ArrayList();
                string html = r.ConvertString(message, arListWithImages).Replace("Trial version can convert up to 30000 symbols.", "").Replace("Get the full featured version!", "");

                //Signature
                string signature = "";
                if (((App)App.Current)._connectedUser.Signature != null)
                {
                    signature = ((App)App.Current)._connectedUser.Signature;
                }

                //Logo
                string image = "<br /><br /><img src=cid:companylogo>";
                string cheminimage = "logo.gif";

                //Adresse
                string adresse = "<br />Tél : +33 (0)2 43 49 17 55 – Fax : +33 (0)2 43 49 02 29<br />P.A des Morandières - Bd de Galilée<br />53810 CHANGE - LAVAL";
                if (((App)App.Current)._connectedUser.Salarie_Interne1 != null)
                {
                    if (((App)App.Current)._connectedUser.Salarie_Interne1.Entreprise_Mere1 != null)
                    {
                        if (((App)App.Current)._connectedUser.Salarie_Interne1.Entreprise_Mere1.AdresseEMail != null)
                        {
                            adresse = ((App)App.Current)._connectedUser.Salarie_Interne1.Entreprise_Mere1.AdresseEMail;
                            cheminimage = ((App)App.Current)._connectedUser.Salarie_Interne1.Entreprise_Mere1.Logo;
                        }
                    }
                }

                //Mentions légales
                string MentLeg = "<br />Ce message (y compris les pièces jointes) est rédigé a l'intention exclusive de ses destinataires et peut contenir des informations confidentielles. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. Si vous n'êtes pas un destinataire, toute utilisation est non-autorisée et peut être illégale. Tout message électronique est susceptible d'altération et son intégrité ne peut être assurée. La société SIT (et ses filiales) décline(nt) toute responsabilité au titre de ce message, dans l'hypothèse ou il aurait été modifié. Merci.<br />This message (including any attachments) is intended solely for the use of the addressee(s) and may contain confidential informations.<br />If you receive this message in error, please delete it and immediately notify the sender.If the reader of this message is not the intended recipient, you are hereby notified that any unauthorized use, copying or dissemination is prohibited. E-mails are susceptible to alteration and their integrity cannot be guaranteed. Neither SIT group nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. Thank you.<br />";

                String contenuMail = html + signature + image + adresse + MentLeg;

                System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(contenuMail, null, "text/html");
                //Lien de l'image CID dans la vue
                LinkedResource logo = new LinkedResource("\\\\stockagenas\\sitaff\\images\\" + cheminimage);
                logo.ContentId = "companylogo";
                htmlView.LinkedResources.Add(logo);

                //Ajout de la vue dans le mail
                msg.AlternateViews.Add(htmlView);

                //ajout de la pj
                Attachment piecejointe = new Attachment(pj);
                msg.Attachments.Add(piecejointe);

                //Ajout de l'adresse mail de la personne qui envoi si elle existe
                if (((App)App.Current)._connectedUser.Salarie_Interne1 != null)
                {
                    if (((App)App.Current)._connectedUser.Salarie_Interne1.Salarie != null)
                    {
                        if (((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne != null)
                        {
                            if (((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail_Pro != null && ((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail_Pro != "")
                            {
                                try
                                {
                                    msg.From = new MailAddress(((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail_Pro);
                                    msg.CC.Add(new MailAddress(((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail_Pro));
                                }
                                catch (Exception) { }
                            }
                            else
                            {
                                if (((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail != null && ((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail != "")
                                {
                                    try
                                    {
                                        msg.From = new MailAddress(((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail);
                                        msg.CC.Add(new MailAddress(((App)App.Current)._connectedUser.Salarie_Interne1.Salarie.Personne.EMail));
                                    }
                                    catch (Exception) { }
                                }
                            }
                        }
                    }
                }

                // Configuration SMTP
                client = new SmtpClient(SMTP, portSMTP);
                client.EnableSsl = false;
                client.Credentials = new NetworkCredential(SMTPUser, MDPSMTPUser);

                // Envoi du mail
                client.Send(msg);

                //Tue le mail
                msg.Dispose();
                //Ferme la connexion au SMTP
                client.Dispose();
            }
            catch (Exception ex)
            {
                //Tue le mail
                if (msg != null)
                {
                    msg.Dispose();
                }
                //Ferme la connexion au SMTP
                if (client != null)
                {
                    client.Dispose();
                }
                throw new Exception(ex.Message);
            }
        }
示例#16
0
        static void Main(string[] args)
        {
            string inpFile = @"..\..\images.rtf";

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            try
            {
                r.OpenRtf(inpFile);

                // Case "1" - store image as separate *.png files in subfolder "filename.images".
                string outFile = Path.Combine(Directory.GetCurrentDirectory(), "case 1.html");

                // The image folder must be already existed.
                r.ImageStyle.ImageFolder = Path.GetDirectoryName(outFile);

                // If subfolder is not exist, it will be created by the component.
                r.ImageStyle.ImageSubFolder = "case 1.images";

                // A template name for images.
                r.ImageStyle.ImageFileName = "picture";

                // Don't embed images inside HTML document.
                r.ImageStyle.IncludeImageInHtml = false;

                // Assume, that we already have 100 images in the subfolder, let's start to name images from 101.
                r.ImageStyle.ImageNumStart = 101;
                r.ImageStyle.ImagesFormat  = SautinSoft.RtfToHtml.eImageFormat.Png;

                // Case "1" - convert to HTML and Show the result.
                r.TextStyle.Title = "Case 1 - PNG files";
                r.ToHtml(outFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });

                // Case "2" - store image as separate *.jpeg files in subfolder "filename.images".
                outFile = Path.Combine(Directory.GetCurrentDirectory(), "case 2.html");
                r.ImageStyle.ImagesFormat = SautinSoft.RtfToHtml.eImageFormat.Jpg;
                r.TextStyle.Title         = "Case 2 - JPEG files";
                r.ToHtml(outFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });

                // Case "3" - skip images.
                outFile = Path.Combine(Directory.GetCurrentDirectory(), "case 3.html");
                r.ImageStyle.PreserveImages = false;
                r.TextStyle.Title           = "Case 3 - No images";
                r.ToHtml(outFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });

                // Case "4" - embed images inside HTML document using base64.
                outFile = Path.Combine(Directory.GetCurrentDirectory(), "case 4.html");
                r.ImageStyle.PreserveImages     = true;
                r.ImageStyle.IncludeImageInHtml = true;
                r.TextStyle.Title = "Case 4 - Embedded images";
                r.ToHtml(outFile);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                {
                    UseShellExecute = true
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
                Console.WriteLine("Press any key ...");
                Console.ReadKey();
            }
        }
示例#17
0
        private void exportToHMTLDatabseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string rtf = "", html = "";
            int id = 0, category_id = 0;
            string name = "", note_text = "";
            // get test text from database
            for (int i = 1; i < 109; i++)
            {
                StringBuilder query = new StringBuilder();
                query.Append("SELECT id, category_id, name, note_text ");
                query.Append("FROM notes ");
                query.Append("WHERE id=" + i);

                using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), dbConnection))
                {
                    using (SQLiteDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (dr.IsDBNull(0))
                                continue;
                            else
                            {
                                id = dr.IsDBNull(0) ? 0 : dr.GetInt32(0);
                                category_id = dr.IsDBNull(1) ? 0 : dr.GetInt32(1);
                                name = dr.IsDBNull(2) ? "" : dr.GetString(2);
                                note_text = dr.IsDBNull(3) ? "" : dr.GetString(3);
                            }
                        }
                    }
                }

                rtf = note_text;
                SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
                r.Encoding = SautinSoft.eEncoding.UTF_8;
                r.OutputFormat = SautinSoft.eOutputFormat.HTML_32;
                html = r.ConvertString(rtf);
                note_text = html;

                StringBuilder insert = new StringBuilder();
                insert.Append("INSERT into Notes_Backup (id, category_id, name, note_text) ");
                insert.Append("VALUES (" + id + ", " + category_id + ", '" + name.Replace("'", "''") + "', '" + note_text.Replace("'", "''") + "')");

                using (SQLiteCommand cmd = new SQLiteCommand(insert.ToString(), dbConnection))
                {
                    using (SQLiteDataReader dr = cmd.ExecuteReader())
                    {
                        //MessageBox.Show(dr.ToString());
                    }
                }
            }
        }
示例#18
0
        static void Main(string[] args)
        {
            string rtfFile = Path.GetFullPath(@"..\..\images.rtf");

            // 1. Convert RTF to HTML and place all images to list
            string rtfString = File.ReadAllText(rtfFile);

            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
            r.ImageStyle.IncludeImageInHtml = false;
            List <SautinSoft.RtfToHtml.SautinImage> imageList = new List <SautinSoft.RtfToHtml.SautinImage>();

            // 2. After launching this method we'll get our RTF document in HTML format
            // and list of all images.
            r.OpenRtf(rtfString);
            string htmlString = String.Empty;

            r.ToHtml(out htmlString, imageList);

            // 3. Create HTML email
            string from    = "*****@*****.**";
            string to      = "*****@*****.**";
            string subject = "This is a testing email from Bob to John using SmtpClient";

            MailMessage emailMessage = new MailMessage();

            emailMessage.From = new MailAddress(from);
            emailMessage.To.Add(to);
            emailMessage.Subject = subject.Replace("\r\n", "");

            // 4. Attach images to email
            System.Net.Mail.AlternateView altView = AlternateView.CreateAlternateViewFromString(htmlString, null, "text/html");

            foreach (SautinSoft.RtfToHtml.SautinImage simg in imageList)
            {
                if (simg.Img != null)
                {
                    LinkedResource         lr = null;
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    simg.Img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    if (ms != null && ms.Position > 0)
                    {
                        ms.Position = 0;
                    }
                    lr           = new LinkedResource(ms);
                    lr.ContentId = simg.Cid;
                    altView.LinkedResources.Add(lr);
                }
            }
            emailMessage.AlternateViews.Add(altView);

            // 5. Send the message using email account
            string userName     = "******";
            string userPassword = "******";

            SmtpClient client = new SmtpClient();

            client.Port           = 25;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;

            //client.UseDefaultCredentials = false;

            // Some smtp servers doesn't require credentials, therefore
            // you may set: client.UseDefaultCredentials = false;
            // and remove the line: client.Credentials = new NetworkCredential(userName, userPassword);

            client.Credentials = new NetworkCredential(userName, userPassword);
            client.Host        = "smtpout.bobsite.com";

            // In the real example in case of the correct host, uncomment the line below:
            //client.Send(emailMessage);
            Console.WriteLine("The message has been sent!");
            Console.ReadKey();
        }