<?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>Matthew Steven Kelly &#187; ASP</title>
	<atom:link href="http://www.matthewstevenkelly.com/blog/tag/asp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.matthewstevenkelly.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 05 Feb 2012 04:43:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ASP Classic Email</title>
		<link>http://www.matthewstevenkelly.com/blog/random/asp-classic-email.html</link>
		<comments>http://www.matthewstevenkelly.com/blog/random/asp-classic-email.html#comments</comments>
		<pubDate>Wed, 05 Apr 2006 02:57:15 +0000</pubDate>
		<dc:creator>Matthew Steven Kelly</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[ASP]]></category>

		<guid isPermaLink="false">https://www.matthewstevenkelly.com/blog/?p=237</guid>
		<description><![CDATA[Using ASP Classic and need to send an email? This is done using CDO, a built component of ASP, and an SMTP server that allows message relay. This website lists the SMTP variables needed based on your email provider, if &#8230; <a href="http://www.matthewstevenkelly.com/blog/random/asp-classic-email.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using ASP Classic and need to send an email? This is done using CDO, a built component of ASP, and an SMTP server that allows message relay. This website lists the SMTP variables needed based on your email provider, if you are using a shared hosting account or other free-based email account: <a href="http://www.emailaddressmanager.com/tips/mail-settings.html">http://www.emailaddressmanager.com/tips/mail-settings.html</a></p>
<p>If you are using a corporate SMTP server, obviously your settings will the custom to your organization.</p>
<p>Below is an example web form that will send an email. Simply change the email server settings variables to your specific SMTP server:</p>
<div style="height: 100%; width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">
<div>&lt;%</div>
<div>On Error Resume Next</div>
<div>&apos;These are the email server settings</div>
<div>Dim sSendTo, sSMTPServer, sSMTPPort</div>
<div>sSendTo = &quot;someone@somedomain.com&quot;</div>
<div>sSMTPServer = &quot;smtp.server.com&quot;</div>
<div>sSMTPPort = 25</div>
<div>&apos; Get form variables</div>
<div>Dim sEmailAddress, sSubject, sBody, bError</div>
<div>sEmailAddress = Request.Form(&quot;email&quot;)</div>
<div>sSubject = Request.Form(&quot;subject&quot;)</div>
<div>sBody = Request.Form(&quot;body&quot;)</div>
<div>bError = true</div>
<div>If sEmailAddress &lt;&gt; &quot;&quot; Then</div>
<div>&nbsp;&nbsp;Set myMail=CreateObject(&quot;CDO.Message&quot;)</div>
<div>&nbsp;&nbsp;myMail.Subject=sSubject</div>
<div>&nbsp;&nbsp;myMail.From=sEmailAddress</div>
<div>&nbsp;&nbsp;myMail.To=sSendTo</div>
<div>&nbsp;&nbsp;myMail.TextBody=sBody</div>
<div>&nbsp;&nbsp;myMail.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;)=2</div>
<div>&nbsp;&nbsp;&apos;Name or IP of remote SMTP server</div>
<div>&nbsp;&nbsp;myMail.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;)=sSMTPServer</div>
<div>&nbsp;&nbsp;&apos;Server port</div>
<div>&nbsp;&nbsp;myMail.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;)=sSMTPPort </div>
<div>&nbsp;&nbsp;myMail.Configuration.Fields.Update</div>
<div>&nbsp;&nbsp;myMail.Send</div>
<div>&nbsp;&nbsp;set myMail=nothing</div>
<div>&nbsp;&nbsp;If err.number &lt;&gt; 0 Then</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;sMessage = &quot;&lt;h1 style=&apos;color:red;&apos;&gt;An error has occurred sending your email. Please try again.&lt;/h1&gt;&quot;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;bError = true</div>
<div>&nbsp;&nbsp;Else</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;sMessage = &quot;&lt;h1&gt;Successfully sent email. Thank you for your input.&lt;/h1&gt;&quot;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;bError = false</div>
<div>&nbsp;&nbsp;End If</div>
<div>End If</div>
<div>%&gt;</div>
<div>&lt;html&gt;</div>
<div>&lt;body&gt;</div>
<div>&nbsp;&nbsp;&lt;% </div>
<div>&nbsp;&nbsp;If sMessage &lt;&gt; &quot;&quot; Then</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write sMessage</div>
<div>&nbsp;&nbsp;End If</div>
<div>&nbsp;&nbsp;&apos; If there was an error (including no form submitted) display the form</div>
<div>&nbsp;&nbsp;If bError = true Then</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;%&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;table cellpadding=0 cellspacing=0&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;Email Address&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;email&quot; value=&quot;&lt;% </div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write sEmailAddress</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;%&gt;&quot;&gt;&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;Subject&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;subject&quot; value=&quot;&lt;% </div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write sSubject</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;%&gt;&quot;&gt;&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;Body&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input type=&quot;text&quot; name= &quot;body&quot; value=&quot;&lt;% </div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;Response.Write sBody</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;%&gt;&quot;&gt;&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&amp;nbsp;&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Send Email&quot;&gt;&lt;/td&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;%</div>
<div>&nbsp;&nbsp;End If</div>
<div>&nbsp;&nbsp;%&gt;</div>
<div>&lt;/body&gt;</div>
<div>&lt;/html&gt;</div>
</div>
<p>More advanced functionality can be added by adding the following syntax to the above example before the <i>myMail.Send</i> line of code&#8230;</p>
<div style="margin-top:20px;">
Sending HTML formatted emails:
<div style="width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">myMail.HTMLBody = sSubject</div>
</div>
<div style="margin-top:20px;">
Sending emails with carbon copies or blind carbon copies:
<div style="width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">myMail.Cc = &quot;example@email.com&quot;<br />
myMail.Bcc = &quot;example@email.com&quot;</div>
</div>
<div style="margin-top:20px;">
Sending HTML formatted emails from a file on your computer:
<div style="width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">myMail.CreateMHTMLBody &quot;file://c:/html-email.htm&quot;</div>
</div>
<div style="margin-top:20px;">
Using SMTP server authentication (replace username and password with your values and add before the <i>myMail.Configuration.Fields.Update</i> line):
<div style="width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">
<div>&apos;SMTP server username</div>
<div>myMail.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusername&quot;)=&quot;username&quot;</div>
<div>&apos;SMTP server password</div>
<div>myMail.Configuration.Fields.Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendpassword&quot;)=&quot;password&quot;</div>
</div>
</div>
<div style="margin-top:20px;">
Adding attachments:
<div style="width: 100%; overflow: auto; background-color: #CCCCCC; font-family: Verdana;">myMail.AddAttachment &quot;c:\attachment.pdf&quot;</div>
</div>
<div style="margin-top:20px;">
Additional Note:the CDONTs functionality in ASP has been discontinued. If you are using CDONTs to send emails you should upgrade to the CDO example shown above.
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewstevenkelly.com/blog/random/asp-classic-email.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

