La fonction ci-dessous s'utilise de la manière suivante dans
une page ASP:
<%
SendMail( "me@me.com", "dest@societe.com", "Sujet
de mon message", "Texte de mon message")
%>
Const cHtmlFormat = 0
Const cTextFormat = 1
'--------------------------------------------------
' Function : SendMail( inFrom, inDest, inSub, inBody)
' Parameters :
' Str inFrom sender recipient mail address
' Str Indest destination recipient mail address
' Str InSub message subject
' Str InBody message body
' Return value :
' 0 if no error occured
' error code
' Purpose : Send email in text format using ASPMail component
' Comment :
' (c)opyright B2L-CYBER/BBDO
'--------------------------------------------------
Function SendMail( inFrom, inDest, inSub, inBody)
Dim lMail
Set lMail = Server.CreateObject("SMTPsvg.Mailer")
lMail.FromAddress = inFrom
lMail.AddRecipient "", inDest
lMail.Subject = inSub
lMail.BodyText = inBody
' WARNING : Set the RemoteHost corresponding to your SMTP gateway
lMail.RemoteHost = "mail.mycompany.com"
If lMail.Sendmail Then ' Send message
SendMail = 0 ' Email was sent ok, return 0
Else ' Send Failure
SendMail = lMail.Response ' Return error message
End If
Set lMail = Nothing
End Function
|