Information Services >> Help Desk
<% if server_response <> "" or newCaptcha then %>
<% if newCaptcha = False then %>
<% response.write("
Captcha response invalid. Please resubmit the form.
") %>
<% end if %>
<% else %>
<%
'Using CDOsys with Basic authentication in Classic ASP
'assumes form includes at least:
'form_name - senders name
'form_mail - senders email
'form_subject
'form_body
'Because this code uses authentication, it requires access to a mailbox on your account.
'reports 'mailFailed' - true or false
'and 'strErr' - Mail server error response
'and 'strErrCode' - Mail server numerical error response (as string)
'dimension all variables (essential if 'option expicit' used)
dim strHost, strErr, mailFailed
dim strBody, strName, strMail
dim strSubject, strFrom, strTo, strCC, strBCC, strReplyTo
dim strAutoMailbox, strEmPass
'modify for yourDomain *********************************************
'your mail server
strHost = "10.10.1.11"
'address of your outgoing mailbox
'this will appear in the headers as the originating mailbox
'strAutoMailbox = "formmail@ourarea.com"
'password for your AutoMailbox
'strEmPass = "1234"
'the name and email that appears in the "From:" line (can be different to above)
'strFrom = strName & "<" & strMail & ">"
'where to send the mail
strTo = "LMUHelpDesk@lmunet.edu"
'where to send copies (optional)
strCC = ""
strBCC = ""
'************************************************* *********************
'collect details from the form ***************************
strName = Request.Form("Username")
strMail = Request.Form("UserEmail")
'create the "Reply To:" i.e. the name and email of the form user
strFrom = strName & "<" & strMail & ">"
strReplyTo = strName & "<" & strMail & ">"
'create subject string
strSubject = Request.Form("form_subject")
'create Body string
strBody = strBody & "***************************************************" & vbCrLf
strBody = strBody & "MessageType: " & Request.Form("MessageType") & vbcrLf & vbcrLf
strBody = strBody & "Username: " & Request.Form("Username") & vbcrLf & vbcrLf
StrBody = strBody & "Email: " & Request.Form("UserEmail") & vbcrLf & vbcrLf
strBody = strBody & "UserTel: " & Request.Form("UserTel") & vbcrLf & vbcrLf
strBody = strBody & "Classification: " & Request.Form("Classification") & vbcrLf & vbcrLf
strBody = strBody & "Building: " & Request.Form("Building") & vbcrLf & vbcrLf
strBody = strBody & "Room: " & Request.Form("Room") & vbcrLf & vbcrLf
strBody = strBody & "Proposed Date 1: " & Request.Form("inputField1") & vbcrLf & vbcrLf
strBody = strBody & "Proposed Date 2: " & Request.Form("inputField2") & vbcrLf & vbcrLf
strBody = strBody & vbcrLf & "Training Description: " & vbcrLf & vbcrLf & Request.Form("Comments") & vbcrLf
strBody = strBody & "Remote Name: " & Request.ServerVariables("REMOTE_ADDR") & vbcrLf & vbcrLf
strBody = strBody & "Date: " & Date & " " & vbcrLf & vbcrLf
strBody = strBody & "Time: " & time & " " & vbcrLf & vbcrLf
'Adds the referring page and the IP details of sender to the mail body (optional)
'strBody = strBody & "Requested from " & Request.ServerVariables("http_referer") & vbCrLf
'strBody = strBody & "Requested by " & Request.ServerVariables("REMOTE_ADDR") _
'& " at " & Request.ServerVariables("REMOTE_HOST") _
'& ". Server time: " & time & " " & Date & " " & vbcrlf
'note the '_' continuation character, if spreading code to the next line for readability
'send the mail ************************************************** *******
'initialise the error response string
strErr = ""
'Const cdoBasic = 1 'Use basic (clear-text) authentication.
Const cdoSendUsingPort = 2
Dim iMsg
Dim iConf
Dim Flds
Dim sMsg
On Error Resume Next
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
'.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = strAutoMailbox
'.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strEmPass
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strHost
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 100
.Update
End With
With iMsg
Set .Configuration = iConf
.To = strTo 'To
.From = strFrom 'From:
if strReplyTo <> "" then
.ReplyTo = strReplyTo 'add ReplyTo: if exists
end if
if strCC <> "" then
.CC = strCC 'add CC if exists
end if
if strBCC <> "" then
.BCC = strBCC 'add BCC if exists
end if
.Subject = strSubject 'add the subject
.TextBody = strBody 'add the body (this is plain text)
.Send 'send the mail
strErr = Err.description 'response (empty if no problems)
'note: Err.number was not available when tested live
End With
'clean up
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
'prepare report flag and string
if strErr = "" then
mailFailed = false
strErr = "Your mail has been sent."
else
mailFailed = true
end if
%>
<%
'report result
'response.write (strErr)
Response.Redirect "http://www.lmunet.edu/is/thanks.asp"
%>
<%end if%>