WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

SendMail Function.

Summary: Use this function to send e-mails using Persit's ASPEmail COM object.
 
Keywords: ASPEMAIL
EMAIL
PERSITS
Applicable Software: Active Server Pages (ASP)
 
Body:

This function makes it easy to send an e-mail from ASP. It's just a single call. If you are looking for an ASP.NET/.NET version of this function, take a look at the Email class/SendEmail functions.

Function SendMail(SenderEmail, SenderName, RecipEmail, CCEmail, Subject, Body, IsHTMLMsg, FilePath, ErrorMSG)
If Len(SenderEmail) = 0 OR Len(SenderName) = 0 Or Len(Subject) = 0 Or Len(Body) = 0 Then SendMail = False: Exit Function
If IsArray(RecipEmail) = False Then
	If Len(RecipEmail) = 0 Then SendMail = False: Exit Function
Else
	If Len(RecipEmail(0)) = 0 Then SendMail = False: Exit Function
End If

Dim m_iCnt
Dim objMail: Set objMail = Server.CreateObject("Persits.MailSender")
	objMail.Host = cStr(g_sSMTP_SERVER)
	
	objMail.Reset	'Start new mail message
	objMail.From = SenderEmail
	objMail.FromName = SenderName
	
	If IsArray(RecipEmail) Then
		For m_iCnt = 0 To UBound(RecipEmail)
			objMail.AddAddress RecipEmail(m_iCnt)
		Next
	Else
		objMail.AddAddress RecipEmail
	End If
	
	If IsArray(CCEmail) Then
		For m_iCnt = 0 To UBound(CCEmail)
			If Len(CCEmail(m_iCnt)) > 0 Then objMail.AddCC CCEmail(m_iCnt)
		Next
	Else
		If Len(CCEmail) > 0 Then objMail.AddCC CCEmail
	End If
	
	objMail.Subject = Subject
	objMail.Body = Body & ""
	objMail.IsHTML = IsHTMLMsg
	
	If Len(FilePath) > 0 Then
		Dim objFS: Set objFS = Server.CreateObject("Scripting.FileSystemObject")
		Dim blnFS: blnFS = objFS.FileExists(FilePath)
		Set objFS = Nothing
		
		If blnFS Then objMail.AddAttachment FilePath
	End If

	objMail.Send
	If Err <> 0 Then
		ErrorMsg = "Error! " & Err.Number & ". " & Err.Description
		SendMail = False
	Else
		SendMail = True
	End If
Set objMail = Nothing
End Function

To use it, you would do:

Dim bMailSent, sError
    bMailSent = SendMail("dsetzer@27seconds.com", _
        "Douglas Setzer", _
        "sales@27seconds.com", _
        "", _
        "Test Subject", _
        "Test Message", _
        False, _
        "", _
        sError)

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 11:33:15 AM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.