Webpage question: How to use .asp to send email?

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
I used to create an .asp webpage and have it send emails to me. How do write a webpage that will send out an email? I know the cdonts object for asp only works if I have an SMTP server. However, I want it to send the email out to an external SMTP server. Is it possible and how? or another web language that can do it?
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
With Perl and PHP, you could send an email without a local SMTP.
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Originally posted by: ojai00
I'm not a web developer, but can't ColdFusion do something like that?

Yes, you could do that using <cfmail> tag. But is it worth it to buy ColdFusion server to have sending email capability? Perl and PHP interpreters are readily available for free.
 

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
Use JMail. Or if you want spend a few bucks and buy a license of ASPMail.
 

bot2600

Platinum Member
May 18, 2001
2,075
0
76
You can also use cdonts to send to an external SMTP server without any 3rd party components.

Sub sendmail()
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort= 2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout ="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields
Dim txtbody
' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtpservername"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "smtpuser"
.Item(cdoSendPassword) = "smtppassword"
.Update
End With
txtbody="Welcome to the Loser's club! I am sure you will meet many more here!"
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = "loser@loser.com"
.From = "TheLoser"
.Subject = "Welcome to the Loser's Club!"
.TextBody = txtbody
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
end sub

It is kinda large, but it is free and built in to 2000 and XP, it will not work with the cdo object in NT4 though, I believe.

Bot
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Originally posted by: Beau
:confused:

If SMTP server is configured in IIS, you shouldn't have to load the config strings when you call it.

Read here

That's the problem.. he doesn't want SMTP server configured on the web server and I would understand his reason for not wanting to.
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
Thanks everybody, especially bot2600. It works :)

I got another question, how do I insert a carriage return in my output? For example, in constructing the email body, how would I add carriage return / new line? in .asp