'Script to send email using CDO
'Author: Felipe Ferreira 06/07/2007 v2.0
On Error Resume Next
sub send_mail(strPassDA, strPassA, strPassCC, strPassBCC, strPassO, strPassT, strPassAttach)
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Const cdoSendUsingPort = 2
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' CDOSYS configuration for SMTP server.
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.foda.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = strPassA
.From = strPassDA
.CC = strPassCC
.BCC = strPassBCC
.Subject = strPassO
.HTMLBody = strPassT
if strPassAttach<>"" then
.AddAttachment strPassAttach
end if
.Send
End With
' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
end sub
iErrori = "Test1"
strBody = ""
strBody = strBody & "
" & date & " " & time
strBody = strBody & "
Numero Errori : " & iErrori
strBody = strBody & "
" & strErrori
'################ SENDS THE EMAIL############################
send_mail "mane@foda.com", "felipe@foda.com", "", "", "Test EMAIL : " & iErrori, strBody, ""