[green]
'==========================================================================
' NAME: EmailAttachment.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 4/23/2004
'
' COMMENT:
'
' You must customize the entries for oTo, oFrom and oMyIP with the proper company information.
'=====================================[/green]
On Error Resume Next
Dim OFrom, oMyIP, oTo, oFSO, oFirstName, TheMessage, Disclaimer
Const ForReading = 1
Set oFSO=CreateObject("Scripting.FileSystemObject")
[green]
' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.[/green]
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]
[green]
'*************************************************
' Set the company specific information
'*************************************************
' Company Email Address[/green][red]
OFrom = "info@yourcompany.com"[/red][green]
' Set the SMTP server IP [/green][red]
oMyIP = "192.168.1.2" [/red][green]
'Where do you want to send it to?[/green][red]
oTo= customer@company.com[/red]
[green]
'Read the message to be sent[/green]
mPrompt = InputBox("What is the name of the message file?" & vbCrlf & "Example: bigsale.txt")
mSubject= InputBox("What should the Subject of the message be?" & vbCrlf & "Example: Don't miss the big sale!!!")
mAttach = InputBox("Do you want to send an attachment?" & vbCrlf & "Type the file name here or just click OK for no attachment." & vbCrlf & "Example: bigsale.jpg")
TheMessage = ofso.OpenTextFile(mPrompt, ForReading).ReadAll
Disclaimer=ofso.OpenTextFile("disclaimer.txt", ForReading).ReadAll
TheMessage = TheMessage & vbCrLf & Disclaimer
[green]
'Create the CDO connections.[/green]
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
[green]
'SMTP server configuration.[/green]
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
[green]
'// Set the SMTP server address here.[/green]
.Item(cdoSMTPServer) = oMyIP
.Update
End With
[green]
'Set the message properties.[/green]
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oFrom
.Subject = mSubject
.TextBody = TheMessage
End With
[green]
'An attachment can be included.[/green]
If Len(mAttach)>0 Then
iMsg.AddAttachment mAttach
End If
[green]
'Send the message.[/green]
iMsg.Send
MsgBox "Message Sent"