{"id":26094,"date":"2020-04-23T08:54:13","date_gmt":"2020-04-23T06:54:13","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=26094"},"modified":"2020-08-04T18:57:22","modified_gmt":"2020-08-04T16:57:22","slug":"creazione-di-un-messaggio-con-report-pdf-allegato","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/creazione-di-un-messaggio-con-report-pdf-allegato\/","title":{"rendered":"Creazione di un messaggio con report PDF allegato"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente frammento di codice mostra come creare un messaggio e-mail con allegato un PDF generato dalla stampa di un report generato a partire dai dati del form corrente\r\n' Il messaggio viene visualizzato e deve essere inviato dall'utente\r\n\r\ndim CODDOC as string = form.form_state.dmd_ref.DOCUMENT.rowset.fields(\"_CODDOC\").value \r\n\r\ndim ADEST as dbarray = new dbarray()\r\ndim cod_forn = form.findcontrol(\"Notebook1\").controls(1).findcontrol(\"Fornitore1\").findcontrol(\"FornitoreCodice1\").value\r\n\r\nif empty (cod_forn)\r\n\tform.alert(\"Please, fill in the supplier\")\r\nelse \r\n\t\r\n\t' Creo il PDF del report OrderReport.repx\r\n\tDim f as string\r\n\tDim par as new Assocarray()\r\n\tpar(\"NUMDOC\") = CODDOC        \r\n\tf = PrintReportWeb(form.Session, \"OrderReport.repx\", New DBArray, nothing, New DBArray, par, \"PDF\")  ' !!! ATTENZIONE: la chiamata a PrintReportWeb non va MAI inserita all'interno di una transazione\r\n\t\r\n\t' MAIL - ADEST - Recupero l'email del fornitore a cui inviare l'ordine\r\n\tdim email_forn as qwtable = new qwtable\r\n\tdim err as string\r\n\tpar(\"CODFOR\") = cod_forn\r\n\temail_forn = OpenTable(form, \"select email from CLIFOR where CODICE = :CODFOR\", par, false, false, err) \r\n\tif empty(err)\r\n\t\tif email_forn.rowset.first()\r\n\t\t\tADEST.add(email_forn.rowset.fields(1).value)     \r\n\t\tend if\r\n\t\tCloseTable(form, email_forn)\r\n\telse\r\n\t\tform.Alert(err, \"ERRORE\")\r\n\tend if\r\n\t\t\r\n\t' MAIL - Costruzione dell'oggetto della mail \r\n\tdim TIPO_CONT as string = form.findcontrol(\"TIPO_CONT\").Value\r\n\tdim NUMERO as string = form.findcontrol(\"NUMERO\").value\r\n\tdim oggetto_mail as string = \"SOMFY ESPANA - Order n. \" + TIPO_CONT + \"\/\" + NUMERO\r\n\t\t\r\n\t' MAIL - Costruzione del corpo della mail\r\n\tdim corpo_mail as string\r\n\tcorpo_mail =   \"Dear supplier, \" + \"\r\n\" + _\r\n\t\t\t\t\t\t\"   We would like to place the order contained in the attached file.\" + \"\r\n\" + _\r\n\t\t\t\t\t\t\"Please confirm receipt of this order.\" + \"\r\n\" + _\r\n\t\t\t\t\t\t\"\r\n\" + _\r\n\t\t\t\t\t\t\"Yours faithfully,\" + \"\r\n\"\r\n\t\t\r\n\t' MAIL - Costruzione della mail con i campi calcolati in precedenza\r\n\tDim qmail as QWMail = New QWMail\r\n\tqmail.MsgCreate()\r\n\tqmail.MsgFrom(\"noreply@qualiware.it\")\r\n\tqmail.MsgAddDest(adest(1),1)   \r\n\tqmail.MsgSubject(oggetto_mail)\r\n\tqmail.MsgText(corpo_mail)\r\n    qmail.MsgAttachment(oggetto_mail + \".PDF\", Q95_PATH_TEMP + \"\\\" + f)\r\n\tqmail.MsgShow(form)\r\n\t\r\nend if<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &#8216; Il seguente frammento di codice mostra come creare un messaggio e-mail con allegato un PDF generato dalla stampa di un report generato a partire dai dati del form corrente &#8216; Il messaggio viene visualizzato e deve essere inviato dall&#8217;utente dim CODDOC as string = form.form_state.dmd_ref.DOCUMENT.rowset.fields(&#8220;_CODDOC&#8221;).value dim ADEST as dbarray = new dbarray() dim&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[71],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26094"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=26094"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/26094\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=26094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=26094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=26094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}