Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Specific SMTP server using CDONTS

Posted 05 Jan 2004 18:05:10
1
has voted
05 Jan 2004 18:05:10 Dan Berdusco posted:
Good day all. I have created a site using asp and want to use a CDONTS form to send some information. I got the form setup, and it did not work. After talking with the I.T. guy where the site is hosted, he informed me that the server that the website is hosted on does not have an SMTP service running on it. However, he gave me the IP address the server that the SMTP service is running on. Is there any way that I can specify in the CDONTS code a mail server to use?

Thanks in advance. Any help is appreciated.

Replies

Replied 05 Jan 2004 19:00:35
05 Jan 2004 19:00:35 Rene Bandsma replied:
We use this line:

<pre id=code><font face=courier size=2 id=code>cdoConfiguration.Fields(cdoSMTPServer) = "ENTER SMTP OR IP ADDRESS"</font id=code></pre id=code>
Replied 05 Jan 2004 20:04:45
05 Jan 2004 20:04:45 Dan Berdusco replied:
Bandsma, I am not too familiar with this... Where would I place this in my code?

<pre id=code><font face=courier size=2 id=code>&lt;%
On Error Resume Next
Dim myMail
Set myMail = CreateObject("CDONTS.NewMail"

HTML = "&lt;!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN""&gt;" & vbCrLf
HTML = HTML & "&lt;html&gt;"
HTML = HTML & "&lt;head&gt;"
HTML = HTML & "&lt;meta http-equiv=""Content-Type"""
HTML = HTML & "content=""text/html; charset=iso-8859-1""&gt;"
HTML = HTML & "&lt;title&gt;Online Form&lt;/title&gt;"
HTML = HTML & "&lt;/head&gt;"
HTML = HTML & "&lt;body&gt;"
HTML = HTML & "&lt;font face=""Verdana, Arial, Helvetica, sans-serif"" size=""-1""&gt;"
HTML = HTML & "&lt;b&gt;Name:&lt;/b&gt; " & request.form("txtName" & "&lt;br&gt;"
HTML = HTML & "&lt;b&gt;Address:&lt;/b&gt; " & request.form("txtAddress" & "&lt;br&gt;"
HTML = HTML & "&lt;b&gt;Postal Code:&lt;/b&gt; " & request.form("txtPostal" & "&lt;br&gt;"
HTML = HTML & "&lt;b&gt;Phone Number:&lt;/b&gt; " & request.form("txtPhone" & "&lt;br&gt;"
HTML = HTML & "&lt;b&gt;Email Address:&lt;/b&gt; " & request.form("txtEmail" & "&lt;br&gt;&lt;br&gt;"
HTML = HTML & "&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;"

myMail.From = request.form("txtEmail"
myMail.To = " "
myMail.Subject = "the subject of the email"
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.Body = HTML
myMail.Send
Set myMail = Nothing

%&gt;</font id=code></pre id=code>

Thanks for the help...

Replied 06 Jan 2004 12:29:51
06 Jan 2004 12:29:51 Rene Bandsma replied:
<pre id=code><font face=courier size=2 id=code>
&lt;%
On Error Resume Next
Dim myMail
Dim cdoConfiguration

Set myMail = CreateObject("CDO.Message"
Set cdoConfiguration = CreateObject("CDO.Configuration"

cdoConfiguration.Fields(cdoSendUsingMethod) = cdoSendUsingPort
cdoConfiguration.Fields(cdoSMTPServer) = "smtp.yourdomain.com"
cdoConfiguration.Fields.Update
Set myMail.Configuration = cdoConfiguration

</font id=code></pre id=code>


I cannot test teh code, because we use CDOSYS. But when you google to "cdonts example" you get a lot of examples. You can also go the the MSDN.com.

I'm not a die-hard coder, but a Trial and Error coder. If you wish, I can send you our CDOSYS (not CDONTS) code by e-mail.
Replied 02 Feb 2004 16:10:59
02 Feb 2004 16:10:59 Lee Diggins replied:
Hi

Just for clarity.

You can only use CDONTS on the server which SMTP service is installed so if you have your web pages and the SMTP server on one machine then it'll work. If you need to specify an alternate server, which you do, to use it's SMTP service, then CDOSYS is the way to do this.

There are two parts to the code you need to setup, the 'configuration' and the 'message', which is almost a combination of both flexman44s' and bandsmas' code.

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 02 Feb 2004 17:14:59
02 Feb 2004 17:14:59 Dan Berdusco replied:
Digga,

Could you post some sample code, combining the two codes from above, and show us what you mean?

Replied 04 Feb 2004 18:38:58
04 Feb 2004 18:38:58 Lee Diggins replied:
Hi flexman44

Here's the sample code, I've kept it as simple as possible as there are many other properties available for you to set in CDOSYS than in CDONTS, you can use MHTML, BodyPart, FollowUp, Attachment etc. etc., believe me - loads.


<% 
Dim objMyMessage, objMyConfiguration  

' create the message and connection objects 
Set objMyMessage = Server.CreateObject("CDO.Message") 
Set objMyConfiguration = Server.CreateObject ("CDO.Configuration")  
'////////////////////////////////////////////////////////////////
' configuration start
'////////////////////////////////////////////////////////////////
' the target smtp server, you can use IP or SERVERNAME.DOMAINNAME
objMyConfiguration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "servername.domainname.com" 
' the SMTP server port being utilised, normally 25 
objMyConfiguration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
' the CDO port being utlised 
objMyConfiguration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
' connection timeout
objMyConfiguration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
' update the connection
objMyConfiguration.Fields.Update 
' set the message configuration to the connection info defined above 
Set objMyMessage.Configuration = objMyConfiguration 
'////////////////////////////////////////////////////////////////
' configuration end
'////////////////////////////////////////////////////////////////
' message start
'////////////////////////////////////////////////////////////////
Dim strTo, strFrom, strSubject, strBody
strTo = "youremailaddress@yourdomain.com"
strFrom = "myemailaddress@mydomain.com"
strSubject = "Test CDO Email Through Remote SMTP"
strBody = "<h1>Test Successful</h1>"
' the To and From fields are mandatory, if you do not include 
' them the email will not leave the building, so change
' the variables above.
objMyMessage.To = strTo 
objMyMessage.From = strFrom 
objMyMessage.Subject = strSubject 
' the body area can be formatted for HTML and/or plain text
' your options are HTMLBody and TextBody.
' I tend to define both as I am not always happy with the 
' system generated text version of my HTML emails, so I would
' declare a strTextBody and a strHTMLBody variable, more work
' but more control.
objMyMessage.HTMLBody = strBody 
objMyMessage.Send 
'////////////////////////////////////////////////////////////////
' message end
'////////////////////////////////////////////////////////////////
' do a clean-up
Set objMyMessage = Nothing 
Set objMyConfiguration = Nothing 
%> 


Digga

Sharing Knowledge Saves Valuable Time!!!

Edited by - Digga the Wolf on 04 Feb 2004 18:42:38

Reply to this topic