Jan 31 2006

JMail

Posted by admin under Generic sendmail

Function SendEmail( sEmailServer, sFromEmail, sToEmail, sSubject, sText )
   Dim objMail
   set objMail = server.createobject("JMail.SMTPMail")
   objMail.Sender = sFromEmail
   objMail.ServerAddress = sEmailServer
   objMail.AddRecipient  = sToEmail
   objMail.Subject  = sSubject
   objMail.Body = sText
   if objMail.Execute then
     SendEmail = ""
   else
      ' Message send failure
      SendEmail = objMail.Response
   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