<%@language="vbscript"%> <% dim toEmail, fromEmail, emailBody, list toEmail = "youremail@boisestate.edu" fromEmail = "noreply@boisestate.edu" emailBody = "" list = "" %>
<% if not isEmpty (Request.Form ("submit")) then Response.write ("
Submitted your comment
Thank you
") getFields () if (validEmail (Trim (Request.Form ("email")))) then fromEmail = Trim (Request.Form ("email")) end if sendEmail () end if %>

E-mail:

Newsletter? Yes No

Interests: Cooking Sports Computers

 

<% sub getFields () emailBody = "E-mail: " & Request.Form("email") & vbCrLf emailBody = emailBody & "Newsletter: " & Request.Form("newsletter") & vbCrLf emailBody = emailBody & "Interests: " & Request.Form("interests") & vbCrLf emailBody = emailBody & "Comments: " & Request.Form("comments") end sub ' Send confirmation email to 'toEmail' notifying them that there was a new user added. ' Check that 'emailBody' is set and send an email with the applicants ' information. sub sendEmail () if emailBody <> "" then on error resume next Dim cdoconn, mail 'Create the e-mail server object Set mail = Server.CreateObject("CDO.Message") Set cdoconn = Server.CreateObject ("CDO.Configuration") 'Out going SMTP server cdoconn.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay.boisestate.edu" 'SMTP port cdoconn.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'CDO Port cdoconn.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Timeout cdoconn.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 cdoconn.Fields.Update 'Update the CDOSYS Configuration Set mail.Configuration = cdoconn 'Who the e-mail is from mail.From = fromEmail ' mail.bcc = list 'Who the e-mail is sent to mail.To = toEmail 'The subject of the e-mail mail.Subject = "University Web Services: Questions, Comments, Suggestions" 'Set the e-mail body format (HTMLBody=HTML TextBody=Plain) mail.TextBody = emailBody 'Send the e-mail mail.Send Set mail = nothing Set cdoconn = nothing end if end sub ' validate the given email address structure function validEmail(strIn) ' Return true if strIn is in valid e-mail format. dim regex, matches set regex = new Regexp regex.pattern = "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$" set matches = regex.execute (strIn) dim i, match i = 0 ' this should only match once for each match in matches i = i + 1 next ' if i > 0 then we have a valid email address entered validEmail = (i > 0) set regex = nothing set matches = nothing end function %>