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

Inputs

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.

Assumptions

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

Returns

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

Code

'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 = "t_a_r@email.msn.com"
objMail.cc = "" '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.attachments.add("C:MyAttachmentFile.txt")
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

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.