<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Inviare un pdf generato con iTextShapr ad una mail inserita]]></title><description><![CDATA[<p dir="auto">Salve, come da titolo, ho generato un file PDF con iTextSharp e vorrei inviarlo ad una mail inserita all'interno di una textbox.<br />
Dovrebbe essere tutto corretto quando provo a cliccare sul pulsante INVIA mi da il seguente errore su SmtpServer.Send(mail):</p>
<p dir="auto">Il server SMTP richiede una connessione protetta oppure il client non è stato autenticato. Risposta del server: 5.5.1 Authentication Required.</p>
<p dir="auto">Ecco il codice:</p>
<pre><code>            var document = new Document(PageSize.A4, 25, 25, 25, 25);
            var output = new MemoryStream();


            var writer = PdfWriter.GetInstance(document, output);
            document.Open();
            var titleFont = FontFactory.GetFont("Arial", 20, Font.BOLD);
            var subTitleFont = FontFactory.GetFont("Arial", 14, Font.BOLD);
            var boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
            var endingMessageFont = FontFactory.GetFont("Arial", 10, Font.ITALIC);
            var bodyFont = FontFactory.GetFont("Arial", 12, Font.NORMAL);
            document.Add(new Paragraph("", titleFont));
            document.Add(new Paragraph("", bodyFont));
            document.Add(Chunk.NEWLINE);
            document.Add(new Paragraph(titolo, subTitleFont)
            document.Add(Chunk.NEWLINE);
            document.Add(Chunk.NEWLINE);
            document.Close();
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(output.GetBuffer());


            string gMail = "xxx";
            string gPsw = "xxx";


            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(gMail);
            mail.To.Add(new MailAddress(TxtMail.Text));
            mail.Attachments.Add(new Attachment(output, "File.pdf"));


            System.Net.NetworkCredential login = new System.Net.NetworkCredential(gMail, gPsw);
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com", 587);
            SmtpServer.EnableSsl = true;
            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials = login;
            SmtpServer.Send(mail);
</code></pre>
<p dir="auto">Dove sbaglio?</p>
]]></description><link>https://dev.connect.gt/topic/217779/inviare-un-pdf-generato-con-itextshapr-ad-una-mail-inserita</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 23:32:08 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/217779.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 Oct 2015 10:16:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Wed, 07 Oct 2015 21:25:40 GMT]]></title><description><![CDATA[<p dir="auto">Prova a guardare se sull'account gmail (da web) ci sono comunicazioni relative a tentativi di accesso sconosciuti...<br />
Se riconosci l'ip da cui proviene l'applicazione che tenta di inviare allora devi confermare a google che sei tu...</p>
]]></description><link>https://dev.connect.gt/post/1208518</link><guid isPermaLink="true">https://dev.connect.gt/post/1208518</guid><dc:creator><![CDATA[artcava]]></dc:creator><pubDate>Wed, 07 Oct 2015 21:25:40 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Wed, 07 Oct 2015 12:41:30 GMT]]></title><description><![CDATA[<p dir="auto">Con, comunque ho tra virgolette risolto. Il codice funziona correttamente, ora lo posto, ma non riesce ad inviare l'e-mail per questioni di impostazioni account gmail. L'errore è: Impossibile inviare l'e.mail. Suppongo dunque che sia un problema non relativo al codice ma alle impostazioni del server smtp sull'account.</p>
<pre><code>            var mailSender = "smtptest914@gmail.com";
            var pswSender = "XXX";
            var mailReceiver = TxtMail.Text;


            MailMessage mail = new MailMessage(mailSender, mailReceiver);
            mail.Attachments.Add(new Attachment(output, "file.pdf"));                //output è una variabile di MemoryStrem


            SmtpClient client = new SmtpClient();
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            System.Net.NetworkCredential networkCred = new System.Net.NetworkCredential();
            networkCred.UserName = mailSender;
            networkCred.Password = pswSender;
            client.UseDefaultCredentials = true;
            client.Credentials = networkCred;
            client.Port = 993;


            client.Send(mail);
</code></pre>
]]></description><link>https://dev.connect.gt/post/1208521</link><guid isPermaLink="true">https://dev.connect.gt/post/1208521</guid><dc:creator><![CDATA[trese]]></dc:creator><pubDate>Wed, 07 Oct 2015 12:41:30 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Tue, 06 Oct 2015 23:36:24 GMT]]></title><description><![CDATA[<p dir="auto">Ciao Trese, lo UserName, variabile gMail, la metti completa di '@gmail.com' o senza?</p>
]]></description><link>https://dev.connect.gt/post/1208517</link><guid isPermaLink="true">https://dev.connect.gt/post/1208517</guid><dc:creator><![CDATA[artcava]]></dc:creator><pubDate>Tue, 06 Oct 2015 23:36:24 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Sat, 03 Oct 2015 11:48:47 GMT]]></title><description><![CDATA[<p dir="auto">dovresti inserire le credenziali dell'host che usi per spedire la mail</p>
]]></description><link>https://dev.connect.gt/post/1208511</link><guid isPermaLink="true">https://dev.connect.gt/post/1208511</guid><dc:creator><![CDATA[pietror]]></dc:creator><pubDate>Sat, 03 Oct 2015 11:48:47 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Sat, 03 Oct 2015 11:39:59 GMT]]></title><description><![CDATA[<p dir="auto">Purtroppo non ho trovato soluzione nella pagina che mi hai indicato, ho provato tutto ciò che hanno consigliato ma nulla.</p>
<p dir="auto">E' possibile che io sbagli nell'inserire le credenziali? Che credenziali dovrei mettere?</p>
]]></description><link>https://dev.connect.gt/post/1208520</link><guid isPermaLink="true">https://dev.connect.gt/post/1208520</guid><dc:creator><![CDATA[trese]]></dc:creator><pubDate>Sat, 03 Oct 2015 11:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Fri, 02 Oct 2015 13:13:38 GMT]]></title><description><![CDATA[<p dir="auto">potrebbe esser legato ad un problema di sicurezza relativo a google.<br />
Prova a guardare questo link</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not" rel="nofollow ugc">http://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not</a></p>
]]></description><link>https://dev.connect.gt/post/1208510</link><guid isPermaLink="true">https://dev.connect.gt/post/1208510</guid><dc:creator><![CDATA[pietror]]></dc:creator><pubDate>Fri, 02 Oct 2015 13:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Fri, 02 Oct 2015 10:05:48 GMT]]></title><description><![CDATA[<p dir="auto">Grazie per la risposta ma non funziona comunque.</p>
]]></description><link>https://dev.connect.gt/post/1208519</link><guid isPermaLink="true">https://dev.connect.gt/post/1208519</guid><dc:creator><![CDATA[trese]]></dc:creator><pubDate>Fri, 02 Oct 2015 10:05:48 GMT</pubDate></item><item><title><![CDATA[Reply to Inviare un pdf generato con iTextShapr ad una mail inserita on Fri, 02 Oct 2015 09:30:20 GMT]]></title><description><![CDATA[<p dir="auto">prova a mettere UseDefaultCredentials a true</p>
]]></description><link>https://dev.connect.gt/post/1208508</link><guid isPermaLink="true">https://dev.connect.gt/post/1208508</guid><dc:creator><![CDATA[pietror]]></dc:creator><pubDate>Fri, 02 Oct 2015 09:30:20 GMT</pubDate></item></channel></rss>