Please read the below instructions. After reading, please let me know if there is a way to run the script without setting "unattended" as the default. If "unattended isn't the default the script email just sits in the Outlook Outbox. I do not want to change the current default that may be at each workstation that this program is run on.
Thanks.
There are two steps to getting Outlook 2000 to send batch e-mail, using VBScript:
1) Create a "Unattended" Outlook mailing profile.
2) Create a VBScript that will invoke this profile, start outlook, send the message, then exit from Outlook.
Creating the "Mailing Profile"
a) Open the Windows Control Panel and run the "Mail" application.
b) Click on "Show Profiles"
c) Click on "Add"
d) (next screen) make sure only "Internet e-mail" is checked.
e) (next screen) Enter "Unattended" in Profile Name
f) (next screen) click "Setup Mail Account)
g) (next screen)
Mail account: "Unattended"
Name: display name of owner of account
Organization: organization name
e-mail address: Owners "exchange" e-mail address
Reply address: Owners "exchange" reply address
h) (click on "servers" tab
incoming (PoP3): xxxx.xxx.xxxxx.xx.xx
Outgoing (SMTP): xxxx.xxx.xxxxx.xx.xx
Account name: first.last
Password: ********
Check "Remember Password"
check "Log on using Secure password"
check "My server requires authentication"
i) (click on Connection tab)
select "connect using my local area network"
j: (click on advanced tab)
leave at default
k: (click OK)
l: make sure path to mail box ok, then click "next"
m: click "finish"
o: Very Important Step!!!
Open the in the "Control Panel" open the "Mail" application
Select "Profiles"
In the "When starting Microsoft Outlook, use this profile" window, select "Unattended" then click on "close"
This last step is very necessary if you want the VBScript to start outlook unattended and send mail. If the "Unattended" profile is not selected, Outlook will not start properly and the mail will not be sent. The mail will be placed in the "Outbox" of the "Unattended" profile until Outlook is opened with that profile, then the message will be sent.
Now, you are ready to run the script below, without having Outlook running on your computer.
The name of the program is startout.vbs, you should be able to cut and past it to as file and run it from the dos prompt using
c:>cscript startout.vbs
After you change the address to your test e-mail address.
'
' startout.vbs
'
' set up some Outlook constants
FolderCalendar = 9
FolderContacts = 10
FolderDeletedItems = 3
FolderDrafts = 16
FolderJournal = 11
FolderNotes = 12
FolderOutbox = 4
FolderSentMail = 5
FolderTasks = 13
Inbox = 6 ' Inbox folder in Outlook
set ws = CreateObject("WScript.shell"
set fs = CreateObject("Scripting.FileSystemObject"
ProcID = ws.run("d:\office2k\office\outlook.exe",, false)
set loApp = WScript.CreateObject("Outlook.application"
set loSpace = loApp.GetNameSpace("MAPI"
' Logon to the Unattended profile.
loSpace.Logon "Unattended",, True, True
set loMsg = loSpace.GetDefaultFolder(Inbox) ' Points to the inbox
set loNew = loMsg.Items.ADD()
'change the address below to your e-mail address
loNew.Recipients.Add("your.name@tdh.state.tx.us"
loNew.DeleteAfterSubmit = TRUE ' delete these from the SENT folder
' so the SENT folder does not fill up
loNew.Subject = "Test Message from Outlook"
loNew.Body = "This is the test message!"
loNew.Send()
WScript.sleep 5000 ' wait 5 seconds
ws.AppActivate "Inbox - Microsoft Outlook"
WScript.sleep 200
ws.sendkeys "%f" ' alt-f
WScript.sleep 200
ws.sendkeys "x" ' exit
ws.sendkeys "{ENTER}" ' just incase you need an 'enter' key press
' end of VBScript Program
Thanks.
There are two steps to getting Outlook 2000 to send batch e-mail, using VBScript:
1) Create a "Unattended" Outlook mailing profile.
2) Create a VBScript that will invoke this profile, start outlook, send the message, then exit from Outlook.
Creating the "Mailing Profile"
a) Open the Windows Control Panel and run the "Mail" application.
b) Click on "Show Profiles"
c) Click on "Add"
d) (next screen) make sure only "Internet e-mail" is checked.
e) (next screen) Enter "Unattended" in Profile Name
f) (next screen) click "Setup Mail Account)
g) (next screen)
Mail account: "Unattended"
Name: display name of owner of account
Organization: organization name
e-mail address: Owners "exchange" e-mail address
Reply address: Owners "exchange" reply address
h) (click on "servers" tab
incoming (PoP3): xxxx.xxx.xxxxx.xx.xx
Outgoing (SMTP): xxxx.xxx.xxxxx.xx.xx
Account name: first.last
Password: ********
Check "Remember Password"
check "Log on using Secure password"
check "My server requires authentication"
i) (click on Connection tab)
select "connect using my local area network"
j: (click on advanced tab)
leave at default
k: (click OK)
l: make sure path to mail box ok, then click "next"
m: click "finish"
o: Very Important Step!!!
Open the in the "Control Panel" open the "Mail" application
Select "Profiles"
In the "When starting Microsoft Outlook, use this profile" window, select "Unattended" then click on "close"
This last step is very necessary if you want the VBScript to start outlook unattended and send mail. If the "Unattended" profile is not selected, Outlook will not start properly and the mail will not be sent. The mail will be placed in the "Outbox" of the "Unattended" profile until Outlook is opened with that profile, then the message will be sent.
Now, you are ready to run the script below, without having Outlook running on your computer.
The name of the program is startout.vbs, you should be able to cut and past it to as file and run it from the dos prompt using
c:>cscript startout.vbs
After you change the address to your test e-mail address.
'
' startout.vbs
'
' set up some Outlook constants
FolderCalendar = 9
FolderContacts = 10
FolderDeletedItems = 3
FolderDrafts = 16
FolderJournal = 11
FolderNotes = 12
FolderOutbox = 4
FolderSentMail = 5
FolderTasks = 13
Inbox = 6 ' Inbox folder in Outlook
set ws = CreateObject("WScript.shell"
set fs = CreateObject("Scripting.FileSystemObject"
ProcID = ws.run("d:\office2k\office\outlook.exe",, false)
set loApp = WScript.CreateObject("Outlook.application"
set loSpace = loApp.GetNameSpace("MAPI"
' Logon to the Unattended profile.
loSpace.Logon "Unattended",, True, True
set loMsg = loSpace.GetDefaultFolder(Inbox) ' Points to the inbox
set loNew = loMsg.Items.ADD()
'change the address below to your e-mail address
loNew.Recipients.Add("your.name@tdh.state.tx.us"
loNew.DeleteAfterSubmit = TRUE ' delete these from the SENT folder
' so the SENT folder does not fill up
loNew.Subject = "Test Message from Outlook"
loNew.Body = "This is the test message!"
loNew.Send()
WScript.sleep 5000 ' wait 5 seconds
ws.AppActivate "Inbox - Microsoft Outlook"
WScript.sleep 200
ws.sendkeys "%f" ' alt-f
WScript.sleep 200
ws.sendkeys "x" ' exit
ws.sendkeys "{ENTER}" ' just incase you need an 'enter' key press
' end of VBScript Program