Dim Displ Dim colArgs Set colArgs = WScript.Arguments if colArgs.Count < 3 then Call Welcome() Else if colArgs.Count > 3 then Displ = colArgs(3) Else Displ = 1 End If Call SendMessage(colArgs(0), colArgs(1), colArgs(2), Displ) End if Sub SendMessage(uRecipient, uSubject, uAttachmentPath, uDisplayMsg) Dim objOutlook Dim objOutlookMsg Dim objOutlookRecip Dim objOutlookAttach Dim olTo Dim olMailItem olTo = 1 olMailItem = 0 ' Create the Outlook session. Set objOutlook = CreateObject("Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. Set objOutlookRecip = .Recipients.Add(uRecipient) objOutlookRecip.Type = olTo ' Set the Subject, Body, and Importance of the message. .Subject = uSubject .Body = "This is the body of the message." &vbCrLf & vbCrLf ' Add attachments to the message. Set objOutlookAttach = .Attachments.Add(uAttachmentPath) ' Resolve each Recipient's name. For Each ObjOutlookRecip In .Recipients objOutlookRecip.Resolve Next ' Should we display the message before sending? If uDisplayMsg Then .Display Else .Save .Send End If End With Set objOutlook = Nothing End Sub Sub Welcome() MsgBox "This script send files by mail using the Outlook and Windows Scripting Host."&vbCrLf&"Parameters:
[displayitem=0|1]"&vbCrLf&vbCrLf&"(c)2001 Yuri Zaikin"&vbCrLf&"www.zaikin.ru", vbOKOnly + vbInformation, "SendFile" WScript.Quit End Sub