{"id":1069,"date":"2010-09-01T12:54:53","date_gmt":"2010-09-01T15:54:53","guid":{"rendered":"http:\/\/www.radians.com.ar\/blog\/?p=1069"},"modified":"2010-09-01T14:26:24","modified_gmt":"2010-09-01T17:26:24","slug":"agregando-un-disclaimer-a-nuestros-mensajes-salientes-smtp-por-medio-de-un-vbscript-en-exchange-server-2003-howto","status":"publish","type":"post","link":"https:\/\/www.radians.com.ar\/blog\/?p=1069","title":{"rendered":"Agregando un Disclaimer a nuestros mensajes salientes SMTP por medio de un VBScript en Exchange Server 2003 {HOWTO}"},"content":{"rendered":"<p>Hoy vamos a ver como podemos agregar un disclaimer en los mensajes salientes de nuestro Exchange Server 2003 por medio de un VBScript. Para poder hacer esto vamos a necesitar las herramientas <a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?familyid=4afe3504-c209-4a73-ac5d-ff2a4a3b48b7&amp;displaylang=en\">SDK de Exchange<\/a> (Ver secci\u00f3n de links para su descarga). <\/p>\n<p>La instalaci\u00f3n es muy sencilla:<\/p>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK01.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK01\" border=\"0\" alt=\"ExchangeSDK01\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK01_thumb.png\" width=\"544\" height=\"414\" \/><\/a><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK02.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK02\" border=\"0\" alt=\"ExchangeSDK02\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK02_thumb.png\" width=\"544\" height=\"414\" \/><\/a><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK03.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK03\" border=\"0\" alt=\"ExchangeSDK03\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK03_thumb.png\" width=\"544\" height=\"414\" \/><\/a><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK04.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK04\" border=\"0\" alt=\"ExchangeSDK04\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK04_thumb.png\" width=\"544\" height=\"414\" \/><\/a><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK05.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK05\" border=\"0\" alt=\"ExchangeSDK05\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK05_thumb.png\" width=\"544\" height=\"414\" \/><\/a><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK06.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeSDK06\" border=\"0\" alt=\"ExchangeSDK06\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeSDK06_thumb.png\" width=\"544\" height=\"414\" \/><\/a><\/p>\n<p>Ahora tenemos que hacer el script que contendr\u00e1 nuestro Disclaimer. Debe tener el siguiente formato:<\/p>\n<p><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">&lt;SCRIPT LANGUAGE=&quot;VBScript&quot;&gt;     <br \/>Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)      <br \/>&#160;&#160; TextDisclaimer = vbCrLf &amp; &quot;DISCLAIMER:&quot; &amp; vbCrLf &amp; &quot;This message is intended only for the use of the individual or entity to which it is addressed and may contain information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message. If you have received this communication in error, please notify the sender and destroy and delete any copies you may have      <br \/>received.&quot;      <br \/>&#160;&#160; HTMLDisclaimer = &quot;&lt;p&gt;&lt;\/p&gt;&lt;p&gt;DISCLAIMER:&lt;br&gt;This message is intended only for the use of the individual or entity to which it is addressed and may contain information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message. If you have received this communication in error, please notify the sender and destroy and delete any copies you may have      <br \/>received.&quot;<\/font><\/p>\n<p><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">&#160;&#160; If Msg.HTMLBody &lt;&gt; &quot;&quot; Then     <br \/>&#160;&#160;&#160;&#160;&#160; &#8216;Search for the &quot;&lt;\/body&gt;&quot; tag and insert our disclaimer before that tag.      <br \/>&#160;&#160;&#160;&#160;&#160; pos = InStr(1, Msg.HTMLBody, &quot;&lt;\/body&gt;&quot;, vbTextCompare)      <br \/>&#160;&#160;&#160;&#160;&#160; szPartI = Left(Msg.HTMLBody, pos &#8211; 1)      <br \/>&#160;&#160;&#160;&#160;&#160; szPartII = Right(Msg.HTMLBody, Len(Msg.HTMLBody) &#8211; (pos &#8211; 1))      <br \/>&#160;&#160;&#160;&#160;&#160; Msg.HTMLBody = szPartI + HTMLDisclaimer + szPartII      <br \/>&#160;&#160; End If<\/font><\/p>\n<p><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">&#160;&#160; If Msg.TextBody &lt;&gt; &quot;&quot; Then     <br \/>&#160;&#160;&#160;&#160;&#160; Msg.TextBody = Msg.TextBody &amp; vbCrLf &amp; TextDisclaimer &amp; vbCrLf      <br \/>&#160;&#160; End If      <br \/>&#160;&#160;&#160; <br \/>&#160;&#160; &#8216;Commit the content changes to the transport ADO Stream object.      <br \/>&#160;&#160; Msg.DataSource.Save &#8216; Commit the changes into the transport Stream<\/font><\/p>\n<p><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">&#160;&#160; EventStatus = cdoRunNextSink     <br \/>End Sub      <br \/>&lt;\/SCRIPT&gt;      <br \/><\/font><\/p>\n<p>Una vez hecho esto, lo que debemos hacer es registrar el receptor de eventos, utilizando el&#160; archivo <strong><em><font color=\"#ffc000\">Smtpreg.vbs<\/font><\/em><\/strong>. Desde un s\u00edmbolo del sistema, vamos a la carpeta <em><strong><font color=\"#ffc000\">C:\\Program Files\\Exchange SDK\\SDK\\Support\\CDO\\Scripts<\/font><\/strong><\/em> y escribimos lo siguiente:<\/p>\n<ul>\n<li><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">cscript smtpreg.vbs \/add 1 onarrival SMTPScriptingHost CDO.SS_SMTPOnArrivalSink &quot;mail from=*@radians.com.ar&quot;<\/font><\/li>\n<li><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">cscript smtpreg.vbs \/setprop 1 onarrival SMTPScriptingHost Sink ScriptName &quot;C:\\DisclaimerScript.vbs&quot;<\/font><\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeScripts.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"ExchangeScripts\" border=\"0\" alt=\"ExchangeScripts\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images\/AgragndounDisclaimeranuestrosmensajessal_9DF9\/ExchangeScripts_thumb.png\" width=\"543\" height=\"342\" \/><\/a><\/p>\n<p>Si el comando se ejecuta correctamente, aparecer\u00e1 un mensaje de confirmaci\u00f3n generado por la secuencia de comandos.   <br \/>Si por alguna raz\u00f3n queremos desactivar este Script debemos ejecutar lo siguiente: <\/p>\n<ul>\n<li><font color=\"#ff0000\" size=\"2\" face=\"OCR A Extended\">cscript smtpreg.vbs \/remove 1 OnArrival SMTPScriptingHost<\/font><\/li>\n<\/ul>\n<p>Listo ya esta hecho, entonces para probarlo, debemos enviar un mensaje de correo electr\u00f3nico a un destinatario SMTP externo a nuestra organizaci\u00f3n. El destinatario debe recibir un mensaje modificado con nuestro disclaimer al pie del mensaje. Yo no lo puedo probar ahora porque mi entorno virtual no tiene salida externa, pero cr\u00e9anme funciona!; obviamente tiene sus limitaciones, en comparaci\u00f3n con las posibilidades que tenemos en Exchange Server 2007 o 2010; pero bueno es una soluci\u00f3n moment\u00e1nea para quienes tienen aun Exchange Server 2003 en su organizaci\u00f3n, sin tener que adquirir un software de terceros para tal fin.<\/p>\n<p>Espero que les sea de utilidad. Saludos, Roberto Di Lello.<\/p>\n<p><b>Algo muy importante!!!!, s<\/b>i usamos un cliente MAPI, como Microsoft Outlook, para enviar el mensaje de correo electr\u00f3nico, el destinatario no recibir\u00e1 el mensaje modificado. Esto se debe a que los mensajes que se env\u00edan con MAPI no tienen un formato SMTP cuando se desencadena el evento de transporte SMTP. Por tanto, los cambios realizados en el c\u00f3digo del evento no se conservan.<\/p>\n<p>Links con Informaci\u00f3n Adicional:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?familyid=4afe3504-c209-4a73-ac5d-ff2a4a3b48b7&amp;displaylang=en\">Exchange SDK Development Tools<\/a><\/li>\n<li><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms986138(EXCHG.65).aspx\">Microsoft Exchange Server 2003 Software Development Kit<\/a><\/li>\n<li><a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=5ca18d40-5a37-4a20-94ae-6a6cf6cb846d&amp;displaylang=en\">Microsoft Exchange Server 2003 SDK Documentation and Samples June 2007<\/a><\/li>\n<li><a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/cdosys\/html\/7406817f-b48f-4b62-86af-bd6703fca4f6.asp\">&quot;Managing Event Bindings&quot; (Administrar enlaces de eventos)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Hoy vamos a ver como podemos agregar un disclaimer en los mensajes salientes de nuestro&#8230;<\/p>\n","protected":false},"author":1,"featured_media":4291,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange-2003"],"_links":{"self":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1069"}],"version-history":[{"count":1,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions"}],"predecessor-version":[{"id":1070,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions\/1070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/media\/4291"}],"wp:attachment":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}