From 02fe738f674634b3d38c8dfb11db0d1f1a67ddd7 Mon Sep 17 00:00:00 2001 From: Yourdax Date: Mon, 27 May 2024 04:57:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=A0=D0=90=D0=90=D0=90=20=D0=9F=D0=90?= =?UTF-8?q?=D0=90=D0=90=D0=90=D0=9F=D0=90=D0=90=D0=90=D0=90=20=D0=A1=D0=9C?= =?UTF-8?q?=D0=9E=D0=A2=D0=A0=D0=98=20=D0=AF=20=D0=AD=D0=A2=D0=9E=20=D0=A1?= =?UTF-8?q?=D0=94=D0=95=D0=9B=D0=90=D0=9B=20(=D1=8F=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B4=D1=83=D1=80=D0=B0=D0=BA,=20=D0=BF=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BE=D1=87=D0=B5=D0=BD=D1=8C=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B4)))))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DiningRoom/DiningRoomView/FormReportComponentsByDate.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DiningRoom/DiningRoomView/FormReportComponentsByDate.cs b/DiningRoom/DiningRoomView/FormReportComponentsByDate.cs index 8910286..c769853 100644 --- a/DiningRoom/DiningRoomView/FormReportComponentsByDate.cs +++ b/DiningRoom/DiningRoomView/FormReportComponentsByDate.cs @@ -173,10 +173,11 @@ namespace DiningRoomView } } - public void CreateDoc(PdfInfo info, MemoryStream stream) + public void CreateDoc(PdfInfo info, Stream stream) { Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, stream); + writer.CloseStream = false; document.Open(); document.Add(new Paragraph(info.Title, FontFactory.GetFont("Arial", "16", Font.Bold))); @@ -219,10 +220,10 @@ namespace DiningRoomView } private void SendEmailWithPdf(MemoryStream pdfStream, string userEmail) { - pdfStream.Position = 0; // Сбросить позицию потока на начало + pdfStream.Position = 0; MailMessage mail = new MailMessage(); - SmtpClient smtpClient = new SmtpClient("smtp.example.com"); // Замените на SMTP-сервер вашего почтового провайдера + SmtpClient smtpClient = new SmtpClient("smtp.gmail.com"); // Используем SMTP-сервер Gmail mail.From = new MailAddress("mailworker2024@gmail.com"); // Ваш email mail.To.Add(userEmail); @@ -233,7 +234,7 @@ namespace DiningRoomView Attachment attachment = new Attachment(pdfStream, "Report.pdf", "application/pdf"); mail.Attachments.Add(attachment); - smtpClient.Port = 587; // Обычно 587 или 25 для SMTP + smtpClient.Port = 587; // Порт SMTP-сервера Gmail smtpClient.Credentials = new NetworkCredential("mailworker2024@gmail.com", "bixb rbag kumt lefa"); // Ваш email и пароль smtpClient.EnableSsl = true;