Ditribution List Generator





1
Date Submitted Mon. Nov. 6th, 2006 8:12 AM
Revision 1 of 1
Scripter Casper42
Tags "Distribution List" | Outlook | vbs
Comments 0 comments
This script allows the creation of an Outlook Distribution List from a text file. This is handy for creating a quick email distribution list without having to manually add each contact to the list.

I have used it only a couple times, but was born out of a need from a listserv member - they use it almost daily for emailing contacts pulled from a terminal-windowed application and saved as standard output.

Maybe you'll find this useful, maybe not, but thought I'd share it...

'*******************************************************************************
'
Distribution List Generator v0.1
'
'
Jeremy Edmiston (JeremyEdmiston@PointLoma.edu)
' Point Loma Nazarene University
'

' Modified 09/20/2006
'
*******************************************************************************
'
'
Purpose: To create an Outlook Distribution List from a text file
'
'
Usage:   When executed, will browse for a file
'          Can be called with file path as parameter for auto-creation
'

' File:    The file to be loaded must contain one name per row with the format:
'
          [FirstName] [LastName] [EmailAddress]
'          or [Name] [EmailAddress]
'
          or [EmailAddress]
'
'
Warning: Outlook Security will prompt to allow access, this is by design
'
'
*******************************************************************************

On Error Resume Next

'Check for parameter
Set objArgs = WScript.Arguments
if objArgs.Count = 0 then
  Set oFileBrowser = CreateObject("UserAccounts.CommonDialog")
  oFileBrowser.ShowOpen
  oFile = oFileBrowser.FileName
else
  oFile = objArgs(0)
end if

'
Instatiate Outlook
Set oApp = Wscript.CreateObject("Outlook.Application")

'Create the Distribution List Object
Set oDL = oApp.CreateItem(7)

'
Create a mail item (DL do not allow direct access to members by design)
Set oMail = oApp.CreateItem(olMailItem)
Set oRecip = oMail.Recipients

'Open file and process records
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FS = objFSO.OpenTextFile(oFile,1)
i = 0
Do While FS.AtEndOfStream <> True
 strNextLine = FS.Readline
 oRecip.Add strNextLine
 i = i + 1
Loop
FS.Close

'
Add members from the mail recipients
oDL.AddMembers oRecip
oDL.display()

Wscript.Quit
 

Jeremy Edmiston

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Syntax Master dannyboy

Votes Down