<% ' CDO SendMail in it's simplest form. ' ' Example Usage: ' ' SendMail "someone@receive.com", "Test Subject", "Test Message" Sub SendMail(pSendTo,pSubject,pMessage) Set cdoConfig = Server.CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mail.spambat.com" .Update End With Set cdoMessage = Server.CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = "noreply@spambat.com" .To = pSendTo .Subject = pSubject .TextBody = pMessage .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing End Sub Sub SendHTMLEmail(pSendTo,pSubject,pMessage) Set cdoConfig = Server.CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mail.spambat.com" .Update End With Set cdoMessage = Server.CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = "noreply@spambat.com" .To = pSendTo .Subject = pSubject .HtmlBody = pMessage .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing End Sub Sub SendJmail(pSendTo,pSubject,pMessage) set msg = Server.CreateOBject("JMail.Message") With msg .Logging = false .From = gPostmaster .FromName = gSystemName .AddRecipient pSendTo .Subject = pSubject .Body = pMessage .Send(gSMTPServer) End With set msg = nothing End Sub 'Function to Validate Email Address Function IsValidEmail(email) dim atCnt IsValidEmail = True if len(cstr(email)) < 7 then IsValidEmail = False elseif instr(email,"@") = 0 then IsValidEmail = False elseif instr(email,".") = 0 then IsValidEmail = False elseif len(email) - instrrev(email,".") > 3 then IsValidEmail = False elseif instr(email,"_") <> 0 and _ instrrev(email,"_") > instrrev(email,"@") then IsValidEmail = False else atCnt = 0 for i = 1 to len(email) if mid(email,i,1) = "@" then atCnt = atCnt + 1 end if next if atCnt > 1 then IsValidEmail = False end if for i = 1 to len(email) if not isnumeric(mid(email,i,1)) and _ (lcase(mid(email,i,1)) < "a" or _ lcase(mid(email,i,1)) > "z") and _ mid(email,i,1) <> "_" and _ mid(email,i,1) <> "." and _ mid(email,i,1) <> "@" and _ mid(email,i,1) <> "-" then IsValidEmail = False end if next end if End Function '------------------------------------------------------------------------------------------- Sub SendMailFrom(pSendFrom,pSendTo,pSubject,pMessage) Set cdoConfig = Server.CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = gSMTPserver .Update End With Set cdoMessage = Server.CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = pSendFrom .To = pSendTo .Subject = pSubject .TextBody = pMessage .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing End Sub Sub SendHTMLEmailFrom(pSendFrom,pSendTo,pSubject,pMessage) Set cdoConfig = Server.CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = gSMTPserver .Update End With Set cdoMessage = Server.CreateObject("CDO.Message") With cdoMessage Set .Configuration = cdoConfig .From = pSendFrom .To = pSendTo .Subject = pSubject .HtmlBody = pMessage .Send End With Set cdoMessage = Nothing Set cdoConfig = Nothing End Sub %>