<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Monie Studios &#187; cdosys</title>
	<atom:link href="http://www.moniestudios.com/tag/cdosys/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.moniestudios.com</link>
	<description>So much to learn, so little time!</description>
	<lastBuildDate>Fri, 21 Oct 2011 11:30:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Sending E-Mail with CDOSYS</title>
		<link>http://www.moniestudios.com/tutorials/asp-mail-cdosys/</link>
		<comments>http://www.moniestudios.com/tutorials/asp-mail-cdosys/#comments</comments>
		<pubDate>Mon, 18 May 2009 04:27:03 +0000</pubDate>
		<dc:creator>Monie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[cdosys]]></category>
		<category><![CDATA[email]]></category>

		<guid isPermaLink="false">http://www.moniestudios.com/?p=357</guid>
		<description><![CDATA[Learn how you can have your own contact form in your own website with this tutorial on CDOSY.]]></description>
			<content:encoded><![CDATA[<p>Ever wonder how you could send email from your ASP page? Need to create your own contact form but have no clue how to do it? After reading this tutorial, you will find it quiet easy!</p>
<h2>What is CDOSYS?</h2>
<blockquote><p>CDO (Collaboration Data Objects) is a Microsoft technology that is designed to simplify the creation of messaging applications.</p>
<p>CDOSYS is a built-in component in ASP. This component is used to send e-mails with ASP.</p></blockquote>
<p>We all know that whenever you put your email address onto the internet for you to communicate with your visitors, you instantly get hit with tons of spam. This is because a spammer&#8217;s email finder application saw your email address and added it to their nasty hit list.</p>
<p>This is why website owners created a contact form for their visitors to interact with them. With this kind of technology (CDOSYS), you can receive emails from your visitors without letting the general public know your email address, reducing the spammer activity on your site.</p>
<p>This following tutorial will show you how you could send email using ASP built in component to a remote server.</p>
<h2>The Basic HTML</h2>
<p>Before we start worrying about how to send the email, let&#8217;s make a basic HTML form that will gather the following information from the user. Save this file with .htm extension, in this example I&#8217;ll name them as <strong>contact.htm</strong>.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Tutorial: Send Email Using CDOSYS&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form name=&quot;feedback&quot; method=&quot;post&quot; action=&quot;cdosys_mail.asp&quot;&gt;
    Your Name : &lt;input type=&quot;text&quot; name=&quot;txtName&quot;&gt;
    Your Email Address: &lt;input type=&quot;text&quot; name=&quot;txtEmail&quot;&gt;
    Cc: &lt;input type=&quot;text&quot; name=&quot;txtCc&quot;&gt;
    Bcc &lt;input type=&quot;text&quot; name=&quot;txtBcc&quot;&gt;
    Subject: &lt;input type=&quot;text&quot; name=&quot;txtSubject&quot;&gt;
    Comment/Suggestion : &lt;textarea name=&quot;txtComment&quot;&gt;&lt;/textarea&gt;
    &lt;input name=&quot;submit&quot; type=&quot;submit&quot;&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>The CDOSYS</h2>
<p>Now that we have our HTML Form ready, we need to create the ASP file containing the CDOSYS code that will retrieve this data and shoot off an email. All the properties that are set in the following code are self-explanatory and write only. Please take note that a Message is an object, it must be Set equal to nothing after we have finished with it to release the memory allocated to it.</p>
<p>Save this file with .asp extension and in the same directory with your previous html form. In our previous html form, we have a form action pointing to <strong>cdosys_mail.asp</strong> which is the name that we will give to this page.</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%
Dim txtName, txtEmail, txtCc, txtBcc, txtSubject, txtComment, htmlBody
    txtName = Request.Form(&quot;txtName&quot;)
    txtEmail = Request.Form(&quot;txtEmail&quot;)
    txtCc = Request.Form(&quot;txtCc&quot;)
    txtBcc = Request.Form(&quot;txtBcc&quot;)
    txtSubject = Request.Form(&quot;txtSubject&quot;)
    txtComment = Request.Form(&quot;txtComment&quot;)

    htmlBody = &quot;&lt;b&gt;Tutorial: Send Email Using CDOSYS&lt;/b&gt;&lt;br&gt;&quot;
    htmlBody = htmlBody &amp; txtComment

Dim objCDOSYSCon
Set objCDOSYSMail = Server.CreateObject(&quot;CDO.Message&quot;)
Set objCDOSYSCon = Server.CreateObject (&quot;CDO.Configuration&quot;)
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;smtp.server.com&quot;
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;)  = 25 'Your mail SMTP Port Number
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout&quot;) = 60 'Timeout Setting
	objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon
    objCDOSYSMail.From = txtEmail
    objCDOSYSMail.To = webmaster@mywebsite.com 'Set your email address here!
    objCDOSYSMail.Cc = txtCc
    objCDOSYSMail.Bcc = txtBcc
    objCDOSYSMail.Subject = txtSubject
    objCDOSYSMail.HTMLBody = htmlBody
    objCDOSYSMail.Send 'Send the email out

'Clear connection and redirect user
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Set adoCon = Nothing

Response.Redirect &quot;email_successfully_sent_message.asp&quot;
%&gt;
</pre>
<p>Please note that this is a very basic ASP Email Form and is only for tutorial purposes. If you were to use this code on your web site, you would want to do some form validation to make sure the email addresses are valid, compulsory field are filled in, allow for attachments, etc.</p>
<p>That&#8217;s just it. Your site are now ready to received email from your visitors!</p>
<p><a class="mw" href="http://www.moniestudios.com/wp-content/uploads/attachment/cdosys.zip">Download The Full Code</a></p>
<p>Source: <a class="mw" href="http://www.w3schools.com">W3Schools</a> <a class="mw" href="http://www.tizag.com">Tizag</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.moniestudios.com/tutorials/asp-mail-cdosys/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

