|
|
|
Sending a e-mail with attachment using CDO and VbScriptXtra
Added on 9/17/2002
|
The behavior sends a e-mail message with attached file (if any). It uses Microsoft CDO for Windows 2000 Library. CDO (Collaboration Data Objects) are accessed using VbScriptXtra.
To use this behavior replace SMTP server setting to a proper value.
-- Handler uses CDO.Configuration and CDO.Message objects
-- to send e-mail
on SendMail strTo, strText, strFileToAttach
conf = xtra("VbScriptXtra").CreateObject("CDO.Configuration")
if stringP(conf) then
alert conf
exit
end if
conf.fields[conf.cdoSendUsingMethod] = conf.cdoSendUsingPort
conf.fields[conf.cdoSMTPServer].Value = "smtpServerHere"
conf.fields.Update()
mes = xtra("VbScriptXtra").CreateObject("CDO.Message")
mes.Configuration = conf
mes.To = strTo
mes.From = "someone@domain.com"
mes.textBody = strText
--Attaching a file to the message (if any)
if stringP(strFileToAttach) then
mes.AddAttachment(strFileToAttach)
end if
mes.Send()
if mes.failed then alert mes.LastError
-- Voiding out CDO objects to initiate actual message sending
mes=void
conf=void
end
|
|