Create a message with a single file attachment and send it with SMTPClient Object
' Example: CSMail VBScript Example 2
' Summary: Create a message with a single file attachment and send it with the SMTPClient Object
' Usage: cscript exvbs02.vbs
' or
' wscript exvbs02.vbs
set MyMsg=CreateObject("CSMail.Message") ' Create the message object
MyMsg.Subject="Medical Officer's Report" ' Set the message subject
MyMsg.To(1)="kirk@enterprise.com" ' Set the recipient...
MyMsg.From(1)="bones@enterprise.com" ' ... and the originator
MyMsg.Sections(1).Body="Its life Jim, but not as we know it."
' Set the message body text
' Attach a file
' Note - the Content-Type and Content-Transfer-Encoding fields will be set automatically
' by the control
MyMsg.Sections(2).AttachBodyFromFile("V:\test\tribbles.giff")
set SMTP = CreateObject("CSMail.SMTPClient") ' Create an SMTP Client Object
SMTP.Connect("127.0.0.1") ' Connect to the server - in this case the local machine
SMTP.SendMessage(MyMsg) ' Send the message
SMTP.Close ' Close the server
|