Search Tools Links Login

Send Outlook message from script

This allows you to fill out and send an Outlook message from script. Uncomment 2 lines to create a sub that can be included in a larger script. Great for admins who routinely send reports. 'T Runstein

Original Author: T Runstein


The script, as shown, is all hardcoded, but you could easily call "inputbox", or read inputs off a form to fill in the items. If you need help adapting this to your needs, let me know - I'm happy to help you customize it.


As with all .vbs scripts, you must have the scripting runtime. You also need Outlook installed.


You can choose to preview by using the .display, or send without preview by using .send


'Uncomment the sub and
'end sub lines to use this in a program.
'Leaving these commented will allow you
'to run this as a standalone script
'sub SendAttach()
'Open mail, adress, attach report
dim objOutlk 'Outlook
dim objMail 'Email item
dim strMsg
const olMailItem = 0
'Create a new message
set objOutlk = createobject("Outlook.Application")
set objMail = objOutlk.createitem(olMailItem)
objMail.To = "" = "" 'Enter an address here to include a carbon copy; bcc is for blind carbon copy's
'Set up Subject Line
objMail.subject = "I saw your code on Planet Source Code on " & cstr(month(now)) & "/" & cstr(day(now)) & "/" & cstr(year(now))
'Add the body

strMsg = "Your code rocks!" & vbcrlf
strMsg = strMsg & "I voted and gave you an excellent rating!"
'To add an attachment, use:
objMail.body = strMsg
objMail.display 'Use this to display before sending, otherwise call objMail.Send to send without reviewing
'Clean up
set objMail = nothing
set objOutlk = nothing
'end sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 72 times




No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.