{"id":357,"date":"2011-06-22T02:53:04","date_gmt":"2011-06-22T02:53:04","guid":{"rendered":"http:\/\/craftydba.com\/?p=357"},"modified":"2024-02-17T14:25:57","modified_gmt":"2024-02-17T14:25:57","slug":"running-the-smtp-relay","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=357","title":{"rendered":"Running the SMTP relay"},"content":{"rendered":"<p>Today, I want to talk about getting in shape to run the Microsoft Exchange, SMTP Relay. It takes years of practice to get in condition for such a grueling race. I am just kidding!<\/p>\n<p>However, the topic of a <a href=\"http:\/\/en.wikipedia.org\/wiki\/SMTP_relay\">SMTP relay<\/a> is an important one that you will come across in your career. A open mail relay allows a Visual Basic script to send mail messages from a mail box that you can name and does not have to exist on the mail server.<\/p>\n<p>In todays information world, it is very important to stay connected via emails. Emails can be used for many different purposes in your Visual Basic scripts.<\/p>\n<ul>\n<li>Alerting when system thresholds or conditions are met<\/li>\n<li>Notification when automated tasks complete or fail<\/li>\n<li>Delivery of custom reports and messages to users.<\/li>\n<\/ul>\n<p>I have encapsulated the logic for\u00a0running\u00a0the\u00a0SMTP relay, via <a href=\"http:\/\/en.wikipedia.org\/wiki\/Collaboration_Data_Objects\">Collabortion Data Objects<\/a> (CDO), into a abstract class.<\/p>\n<p>The CDO Email class has the following<span style=\"color: #800000;\"> required <\/span>properties.<\/p>\n<p style=\"padding-left: 30px;\">SMTP_SVR &#8211; The DNS name of the MS Exchange (mail) server<br \/>\nFROM_EMAIL &#8211; Any source email address that follows naming conventions.<br \/>\nTO_EMAIL &#8211; A valid destination email address.<br \/>\nMSG_SUBJECT &#8211; A string describing the subject of the message.<br \/>\nMSG_BODY &#8211; A textual or html string that contains the body of the message.<\/p>\n<p>The CDO Email class has the following <span style=\"color: #339966;\">optional <\/span>properties that allow the designer to send HTML message bodies, add multiple attachments, and set mail priority levels.<\/p>\n<p style=\"padding-left: 30px;\">CC_EMAIL &#8211; A valid destination (carbon copy) email address.<br \/>\nBCC_EMAIL &#8211; A valid destination (blind carbon copy) email address.<br \/>\nBODY_TYPE &#8211; Defaults to text. Is required if you want HTML body to be translated.<br \/>\nMSG_ATT = A tilda seperated string of full qualified file names to be attached to the message.<br \/>\nMSG_PRIOIRITY &#8211; A value indicating low (0), normal (1), or high (2) priority.<\/p>\n<p>This class contains two methods that can be called to do the following actions.<\/p>\n<p style=\"padding-left: 30px;\">LOAD_BODY- This method loads a given file as text and save it as the MSG_BODY property.<br \/>\nSEND_EMAIL &#8211; This method creates the message and sends it to the mail server.<\/p>\n<p>The table below has starter code that you can use in your next Visual Basic (VB) Script.<\/p>\n<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\" width=\"600\" align=\"left\">\n<tbody>\n<tr>\n<td style=\"border: thin solid gray;\"><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/mod-cdo-email.vbs_.txt\">mod-cdo-email.vbs<\/a><\/td>\n<td style=\"border: thin solid gray;\">CDO Email Class<\/td>\n<\/tr>\n<tr>\n<td style=\"border: thin solid gray;\"><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/tst-cdo-mail.vbs_.txt\">tst-cdo-mail.vbs<\/a><\/td>\n<td style=\"border: thin solid gray;\">Sample Program<\/td>\n<\/tr>\n<tr>\n<td style=\"border: thin solid gray;\"><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/emails.cmd_.txt\">emails.cmd<\/a><\/td>\n<td style=\"border: thin solid gray;\">Batch Program<\/td>\n<\/tr>\n<tr>\n<td style=\"border: thin solid gray;\"><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/tst-cdo-mail.html\">tst-cdo-mail.html<\/a><\/td>\n<td style=\"border: thin solid gray;\">Sample HTML Message<\/td>\n<\/tr>\n<tr>\n<td style=\"border: thin solid gray;\"><a href=\"http:\/\/en.wikipedia.org\/wiki\/Abraham_Lincoln\">Wikipedia Image<\/a><\/td>\n<td style=\"border: thin solid gray;\">Sample Image Attachment<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/P><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\nThe output below was generated by the execution of the test program with two sub-routines.<br \/>\n<\/P><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\n<a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/emails-by-importance.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/emails-by-importance-150x150.jpg\" alt=\"\" title=\"emails-by-importance\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-408\" \/><\/a><\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/html-email-with-image-att.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2011\/06\/html-email-with-image-att-150x150.jpg\" alt=\"\" title=\"html-email-with-image-att\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-409\" \/><\/a><br \/>\n<\/P><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\nFirst routine creates an text email with varying importance levels. The email notifies users that the Boston Bruins won the Stanley Cup in 2011.<\/p>\n<p>Secound routine creates an HTML email with a image attachment. The focus of this message is the 16th president, Lincoln Abraham.<\/p>\n<p>To recap this discussion, dynamic email creation is used all the time by\u00a0software systems. Adding the SMTP relay component to your VB Script solution will keep you end users aware of recent events.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I want to talk about getting in shape to run the Microsoft Exchange, SMTP Relay. It takes years of practice to get in condition for such a grueling race. I am just kidding! However, the topic of a SMTP relay is an important one that you will come across in your career. A open mail relay allows a Visual Basic script to send mail messages from a mail box that you can name and does not have to exist on the mail server. In todays information world, it is&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[25,12,15,23,13],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-other","tag-email","tag-free-code","tag-john-f-miner-iii","tag-smtp-relay","tag-vb-script-2"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=357"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/357\/revisions"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}