-
Sales
Sales Enquiries
0800 328 7477
- My NetBenefit
Using CDOSYS
This page gives some examples of how to use CDOSYS on NetBenefit Win2K, Win2KCF and Win2003 web space.
- Using CDOSYS to send text formatted messages
- Using CDOSYS to send HTML formatted messages
- Getting CDOSYS to send a carbon copy (CC) or blind carbon copy (BCC)
- Getting CDOSYS to send mail from a "friendly" name
- Example form-to-email
1. Using CDOSYS to send text formatted messages
<%
Set MailObj = CreateObject("CDO.Message")
MailObj.From = "sender@mydomain.com"
MailObj.To = "recipient@theirdomain.com"
MailObj.Subject = "Test message"
Text = "Thank you for your submission." & chr(13) & chr(10)
Text = Text & "Your request is being processed." & chr(13) & chr(10)
Text = Text & "Please allow 48 hours for a response."
MailObj.TextBody = Text
MailObj.Send
Set MailObj = nothing
%>
2. Using CDOSYS to send HTML formatted messages
<%
Set MailObj = CreateObject("CDO.Message")
MailObj.From = "sender@mydomain.com"
MailObj.To = "recipient@theirdomain.com"
MailObj.Subject = "Test message"
HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>Test CDOSYS Email in HTML format</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "<p><font size =""3"" face=""Arial"">"
HTML = HTML & "<b>My Company Ltd.</b><br>"
HTML = HTML & "Your subscription newsletter</p>"
HTML = HTML & "<p align = ""center"">In this newsletter we announce a new product.</p>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
MailObj.HTMLBody = HTML
MailObj.Send
Set MailObj=nothing
%>
3. Getting CDOSYS to send a carbon copy (CC) or blind carbon copy (BCC)
You would include a line such as:
MailObj.Cc = "cc@ccdomain.com"
MailObj.Bcc = "bcc@bccdomain.com"
4. Getting CDOSYS to send mail from a "friendly" name
Enclose the email address in angle brackets, e.g:
MailObj.From = "Mr Sender <sender@mydomain.com>"
5. Example form-to-email
Save the following script as a file called sendmail.asp.
<% Response.Buffer = True %>
<!--- sendmail.asp CDOSYS version--->
<!--- This file is a generic sendmail utility which --->
<!--- takes a form and processes the fields --->
<!--- accordingly. --->
<!--- Hidden control fields should include --->
<!--- recipient:- who to send the email to --->
<!--- subject: - the subject of the mail message --->
<!--- redirect: - next page to show after submission --->
<!--- from: - where the message is coming from. --->
<!--- - This must be a VALID email address. --->
<%
Set MailObj = CreateObject("CDO.Message")
MailObj.From = Trim(Request.Form("from"))
MailObj.To = Trim(Request.Form("recipient"))
MailObj.Subject = Trim(Request.Form("subject"))
Text = ""
For Each FieldName in Request.Form
For Each FieldValue in Request.Form(FieldName)
If LCase(FieldName) = "recipient" Or LCase(FieldName) = "subject"_
Or LCase(FieldName) = "redirect" Or LCase(FieldName) = "from" Then
Else
Text = Text & FieldName & " = " & FieldValue & chr(13) & chr(10)
End If
Next
Next
MailObj.TextBody = Text
MailObj.Send
Set MailObj = nothing
Response.Redirect Request.Form("redirect")
%>
Your form should then contain the special fields: recipient, subject, from, redirect.
The ACTION attribute of the form should be the above script.
<FORM METHOD="POST" ACTION="sendmail.asp">
<INPUT TYPE="HIDDEN" NAME="recipient" VALUE="[YOUR EMAIL ADDRESS]">
<INPUT TYPE="HIDDEN" NAME="subject" VALUE="[SUBJECT FOR MESSAGE]">
<INPUT TYPE="HIDDEN" NAME="redirect" VALUE="[THANKYOU PAGE]">
<INPUT TYPE="HIDDEN" NAME="from" VALUE="[FROM ADDRESS]">
Then have the rest of your form as normal, eg:
Message1:<INPUT TYPE="TEXT" NAME="Message1"><BR>
Message2:<INPUT TYPE="TEXT" NAME="Message2"><BR>
<INPUT TYPE="Submit" VALUE="Send Mail"><BR>
</FORM>






