'************************************** ' Name: Send Outlook message from script ' ' Description:This allows you to fill ou ' t and send an Outlook message from scrip ' t. Uncomment 2 lines to create a sub tha ' t can be included in a larger script. Gr ' eat for admins who routinely send report ' s. 'T Runstein ' By: T Runstein ' ' Inputs:The script, as shown, is all ha ' rdcoded, but you could easily call "inpu ' tbox", 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 ha ' ppy to help you customize it. ' ' Returns:You can choose to preview by u ' sing the .display, or send without previ ' ew by using .send ' ' Assumes:As with all .vbs scripts, you ' must have the scripting runtime. You als ' o need Outlook installed. ' 'This code is copyrighted and has ' limited warranties.Please see http://w ' ww.Planet-Source-Code.com/vb/scripts/Sho ' wCode.asp?txtCodeId=6480&lngWId=4 'for details. '************************************** '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 oNameSpace Dim objSession Dim objMail 'Email item Dim strMsg Const olMailItem = 0 'Create a new message Set objOutlk = createobject("Outlook.Application") Set oNameSpace = objOutlk.GetNamespace("MAPI") Set objSession = CreateObject("MAPI.Session") objSession.Logon("Handel") Set objMail = objOutlk.createitem(olMailItem) objMail.To = "michal.hartleb@datacom.pl" ' 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.send 'Use this To display before sending, otherwise call objMail.Send to send without reviewing 'Clean up Set objMail = nothing Set objOutlk = nothing 'end sub