Jan 31 2006

ASPEmail

Posted by admin under Generic sendmail

Function SendEmail( sEmailServer, sFromEmail, sToEmail, sSubject, sText )
   Dim objMail
   Set objMail = CreateObject("Persits.MailSender")
   objMail.From = sFromEmail
   objMail.Host = sEmailServer
   objMail.AddAddress sToEmail
   objMail.Subject = sSubject
   objMail.Body = sText
   On Error Resume Next
   objMail.Send
   If Err <> 0 Then
       SendEmail =  "An error occurred: " & Err.Description
   End If
   Set objMail = nothing
End Function
 
1. Copy it into a file called incgenmail.asp

2. Include that file from your ASP page supposed to send the mail
<!--#include file="incgenmail.asp"-->


3. Call it like this:
sErrMsg = SendEmail( "smtp.theserver.com",  
           "webmaster@aspcode.net", 
           "John@doe.com", 
           "Important message", 
           "This is an important message bla bla" ) 


4. You can check sErrMsg. If it is "" then mail was sent ok, otherwise there was an error and sErrMsg contains an descriptive text of it.

Links