SunQuest
 
       Windows Scripting
  Home arrow Windows Scripting arrow Building a Mass-Emailer in WSH
Moblin
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Building a Mass-Emailer in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-04-04

    Table of Contents:
  • Building a Mass-Emailer in WSH
  • Creating a mailing list
  • Customizing a form message
  • Wrapping things up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Building a Mass-Emailer in WSH


    (Page 1 of 4 )

    Are you tired of having to manually send the same email to multiple people?  Or maybe you have a spreadsheet full of contacts and would like an easy way to send out a form letter without having to import all of the addresses into your email program.  Or perhaps you’re just looking for a way to schedule an email that emails current sales totals to your staff.  In any case, almost everyone has some kind of use for a mass-mailer.

    You’re going to need the email script you we built in my last article, “Sending Emails Using CDO in WSH.”  In case you missed it, you can download a base script here.

     

    If you haven’t read the previous article, you may feel a little lost in this one.  I will be recapping some important points, but for the most part I will only be covering new material.

    Let’s get started by taking our previous script and packaging it into a nice subroutine.  Since we’re going to be sending multiple emails at once, we’ll need an easy way to keep recalling this portion of our script.  I’ve also replaced all data portions with corresponding variable names.  You can see my subroutine here.

    Sub SendMail

       objMessage.From = strFromEmail

       objMessage.To = strToEmail

       objMessage.Subject = strSubject

       objMessage.HTMLBody = strBody

       objMesasge.AutoGenerateTextBody = True

       objMessage.Configuration.Fields.Item _

           ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

       objMessage.Configuration.Fields.Item _

       ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

           "smtp.mail.com"

       objMessage.Configuration.Fields.Item _

       ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _

           = 25

       objMessage.Configuration.Fields.Update

       objMessage.Send

    End Sub

    With that done, we can now piece together the beginning of the script.  All I’m going to do is list my default variables and create the CDO message object.

    strFromEmail = "My Name <me@mymail.com>"

    strSubject = "Daily Sales Recap"

    strBody = "C:salesdailyreport.htm"

     

    Set objMessage = CreateObject("CDO.Message")

    Here, I’m just assuming that dailyreport.htm is an HTML formatted document that I want to send as the body of my email.  You could easily append to this as necessary or even include a text string containing a custom HTML message.

    With our base script in place, we’re ready to get down to business.

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · Learn how to create a mass-mailer using CDO in WSH. You'll be able to build and...
     

    WINDOWS SCRIPTING ARTICLES

    - Understanding Procedures in VBScript
    - Printing Documents in WSH
    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory

    Iron Speed




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway