Running the SMTP relay

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 very important to stay connected via emails. Emails can be used for many different purposes in your Visual Basic scripts.

  • Alerting when system thresholds or conditions are met
  • Notification when automated tasks complete or fail
  • Delivery of custom reports and messages to users.

I have encapsulated the logic for running the SMTP relay, via Collabortion Data Objects (CDO), into a abstract class.

The CDO Email class has the following required properties.

SMTP_SVR – The DNS name of the MS Exchange (mail) server
FROM_EMAIL – Any source email address that follows naming conventions.
TO_EMAIL – A valid destination email address.
MSG_SUBJECT – A string describing the subject of the message.
MSG_BODY – A textual or html string that contains the body of the message.

The CDO Email class has the following optional properties that allow the designer to send HTML message bodies, add multiple attachments, and set mail priority levels.

CC_EMAIL – A valid destination (carbon copy) email address.
BCC_EMAIL – A valid destination (blind carbon copy) email address.
BODY_TYPE – Defaults to text. Is required if you want HTML body to be translated.
MSG_ATT = A tilda seperated string of full qualified file names to be attached to the message.
MSG_PRIOIRITY – A value indicating low (0), normal (1), or high (2) priority.

This class contains two methods that can be called to do the following actions.

LOAD_BODY- This method loads a given file as text and save it as the MSG_BODY property.
SEND_EMAIL – This method creates the message and sends it to the mail server.

The table below has starter code that you can use in your next Visual Basic (VB) Script.

mod-cdo-email.vbs CDO Email Class
tst-cdo-mail.vbs Sample Program
emails.cmd Batch Program
tst-cdo-mail.html Sample HTML Message
Wikipedia Image Sample Image Attachment





The output below was generated by the execution of the test program with two sub-routines.







First routine creates an text email with varying importance levels. The email notifies users that the Boston Bruins won the Stanley Cup in 2011.

Secound routine creates an HTML email with a image attachment. The focus of this message is the 16th president, Lincoln Abraham.

To recap this discussion, dynamic email creation is used all the time by software systems. Adding the SMTP relay component to your VB Script solution will keep you end users aware of recent events.

Related posts

11 Thoughts to “Running the SMTP relay”

  1. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all website owners and bloggers made good content as you did, the net will be much more useful than ever before.

  2. Yay google is my world beater assisted me to find this outstanding internet site ! . “A tough lesson in life that one has to learn is that not everybody wishes you well.” by Dan Rather.

  3. I like this web blog very much, Its a rattling nice spot to read and get information. “There are two ways of spreading light to be the candle or the mirror that reflects it.” by Edith Newbold Jones Wharton.

  4. Keep up the fantastic work, I read few posts on this website and I conceive that your web site is rattling interesting and has got circles of superb info.

  5. You have remarked very interesting details! Nice internet site.

  6. I like what you guys are doing. Such clever work and reporting! Keep up the superb works guys. I have incorporated you guys to my blogroll. I think it will improve the value of my web site. :)

  7. I like this web blog very much, Its a really nice position to read and receive info. “What is a committee A group of the unwilling, picked from the unfit, to do the unnecessary.” by Richard Harkness.

  8. Nice read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch since I found it for him smile Therefore let me rephrase that: Thanks for lunch! “They may forget what you said, but they will never forget how you made them feel.” by Carl W. Buechner.

  9. I am often to blogging and i really appreciate your content. The article has really peaks my interest, thanks.

  10. I believe that is among the so much vital info for me. And i am satisfied studying your article. But should observation on few normal things, The web site taste is wonderful, the articles is in point of fact nice :D. Excellent activity, cheers.

  11. As a Newbie, I am constantly searching online for articles that can benefit me. Thank you!

Leave a Reply to Michael Antony Cancel reply