{"id":24944,"date":"2017-11-20T10:08:04","date_gmt":"2017-11-20T09:08:04","guid":{"rendered":"http:\/\/help.qualiware.it\/qw-help\/?p=24944"},"modified":"2025-12-23T19:33:28","modified_gmt":"2025-12-23T18:33:28","slug":"lettura-delle-proprieta-di-un-e-mail-da-file-msg-o-eml","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/lettura-delle-proprieta-di-un-e-mail-da-file-msg-o-eml\/","title":{"rendered":"Lettura delle propriet\u00e0 di un e-mail da file .MSG o .EML"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente snippet pu\u00f2 essere utilizzato per leggere le propriet\u00e0 di un e-mail salvata in formato .MSG o .EML tramite il componente MsgReader presente a partire dalla release 2015.17.2p\r\n' L'esempio si riferisce alla generazione di un ticket a partire da una e-mail, determinando il codice del cliente utilizzando il dominio del mittente della e-mail stessa.\r\ndim path as string=&lt;inserire qui il percorso del file .MSG o .EML&gt;\r\n  dim q as qwtable\r\n  \r\n  form.findcontrol(\"TICKET\").Value=\"TT\"+form.findcontrol(\"TIPO_CONT\").Value+\"-\"+form.findcontrol(\"NUMERO\").Value\r\n  \r\n  dim msg As new MsgReader.Outlook.Storage.Message(path)\r\n  \r\n  q = new qwtable\r\n  q.database=form.form_state.dmd_ref.DB\r\n  q.sql=\"select TOP 1 c.CODICE,c.RAGSOC,o.DESCPER,o.EMAIL,o.TELINT,o.DESCRUO from ORGCF o join CLIFOR c on o.CODICE=c.CODICE where o.EMAIL=:EMAIL and (c.CLIENTE=:VERO) and left(c.CODICE,1)&lt;&gt;'*' and left(c.CODICE,1)&lt;&gt;'R' order by c.CODICE desc\"\r\n  q.requestlive=false\r\n  q.params(\"VERO\")=true\r\n  q.requestlive=false\r\n\r\n  ' Cerca nell\"organigramma l\"indirizzo del sender\r\n  q.params(\"EMAIL\")=msg.sender.email\r\n  q.active=true\r\n  if q.rowset.first()\r\n\tform.findcontrol(\"Cliente\").Value=q.rowset.fields(\"CODICE\").value\r\n\tform.findcontrol(\"SEGN\").Value=q.rowset.fields(\"DESCPER\").value+\" (\"+q.rowset.fields(\"DESCRUO\").value+\")\"\r\n\tform.findcontrol(\"SEGN_MAIL\").value=q.rowset.fields(\"EMAIL\").value\r\n\tform.findcontrol(\"SEGN_TEL\").value=q.rowset.fields(\"TELINT\").value\r\n  else\r\n\tform.findcontrol(\"SEGN\").Value=msg.sender.displayname\r\n\tform.findcontrol(\"SEGN_MAIL\").value=msg.sender.email\r\n  End If\r\n  q.active=false\r\n\r\n  if empty(form.findcontrol(\"Cliente\").Value) and dbdollar(\"@\",msg.sender.email)\r\n\t' Prova con il dominio\r\n\tq.sql=\"select CODICE,RAGSOC from CLIFOR c where EMAIL like '%'+:EMAIL and (CLIENTE=:VERO)  and left(c.CODICE,1)&lt;&gt;'*'\"\r\n\tq.params(\"VERO\")=true\r\n\tq.params(\"EMAIL\")=substr2(msg.sender.email,at(\"@\",msg.sender.email)+1)\r\n\tq.active=true\r\n\tif q.rowset.first()\r\n\t   form.findcontrol(\"Cliente\").Value=q.rowset.fields(\"CODICE\").value\r\n\tEnd If\r\n\tq.active=false\r\n  End If\t\r\n\t \r\n  if not empty(form.findcontrol(\"Cliente\").Value)\r\n\t form.SetAssigned(form.findcontrol(\"Cliente\"),true)\r\n\t Cliente_Change(form,form.findcontrol(\"Cliente\"))\r\n  else\r\n\t form.findcontrol(\"SEGN_MAIL\").value=msg.sender.email\t \r\n  End If\r\n\t\r\n  dim cc as string=\"\"\r\n\t\r\n  dim r as integer\r\n  for r=0 to msg.recipients.count-1\r\n \t if msg.recipients.item(r).type=2\r\n\t\tcc+=iif(cc&lt;&gt;\"\",\";\",\"\")+msg.recipients.item(r).email\r\n\t End If\r\n  next\r\n\t \r\n form.findcontrol(\"CC\").value=cc\r\n\t\t  \r\n ' dim d as date=ctype(msg.ReceivedOn,date) --&gt; Per versioni precedenti la 2025.00.21 Fix Pack 7\r\n dim d as date=Ctype(msg.ReceivedOn,DateTimeOffset).DateTime\r\n form.findcontrol(\"DSEGN\").Value=new date(d.year,d.month,d.day)\r\n form.findcontrol(\"HSEGN\").Value=Transform(d.hour,\"@L 99\")+transform(d.minute,\"@L 99\")\r\n \r\n form.findcontrol(\"Notebook1\").controls(0).findcontrol(\"SEGN_TESTO\").value=msg.BodyText\r\n \r\n if not dbdollar(\"Richiesta di assistenza\",msg.subject)\r\n\tform.findcontrol(\"TITOLO\").Value=msg.subject+\" (#\"+form.findcontrol(\"TICKET\").value+\") - \"+form.findcontrol(\"Cliente\").value\r\n else\r\n\tform.findcontrol(\"TITOLO\").Value=msg.subject+\" (#\"+form.findcontrol(\"TICKET\").value+\")\"\r\n End If\r\n\t \r\n form.Save()   \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &#8216; Il seguente snippet pu\u00f2 essere utilizzato per leggere le propriet\u00e0 di un e-mail salvata in formato .MSG o .EML tramite il componente MsgReader presente a partire dalla release 2015.17.2p &#8216; L&#8217;esempio si riferisce alla generazione di un ticket a partire da una e-mail, determinando il codice del cliente utilizzando il dominio del mittente&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\/24944"}],"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=24944"}],"version-history":[{"count":2,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/24944\/revisions"}],"predecessor-version":[{"id":38299,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/24944\/revisions\/38299"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=24944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=24944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=24944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}