Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send email when form is submit

Status
Not open for further replies.

cat5ive

MIS
Dec 3, 2004
184
US
Hi,

I have asp page that contain a form. When user click submit the form submit itself. I need to add a logic that when user click submit then it send out email to notify me. This process will not interrupt the user. In other word, user will not know that it send out the email. Can any one provide sample?

Thank

pagea.asp
Code:
<table cellspacing="0" cellpadding="0" border="0" bgcolor="#edecd7">
<form action="pagea.asp?" method="post" name="f1">
 
Thank you Sheco. I just tried it. It did not work. I did not receive the mail and no error message either.
The code after email got processed (call cgi to update file). So I know for sure that it fall in this module. Only the emailing does not work.

Code:
if strrcdcnt > "0"  then  'record count > 0 after submit itself 
'send email

Set myMail = CreateObject("CDO.Message")
    myMail.Subject = "Sending email with CDO"
    myMail.From = "rapeek@carmnet.com"
    myMail.To = "rapeek@carmnet.com"
    myMail.TextBody = strvendorcode
    myMail.Send
    set myMail = nothing

' doing some more things here

thanks
 
Is the SMTP service running on your IIS box? If not then start it. If it is running then look in the folders named inetpub\mailroot\queue and also inetpub\mailroot\badmail
 
Hi Sheco,

I found a sample code from another website before see your reply. It's a lot more complicate but it's work. Do you happen to know what's the different?
Code:
Const cdoBasic = 1 'Use basic (clear-text) authentication. 
Const cdoSendUsingPort = 2 

Dim iMsg
Dim iConf
Dim Flds

'On Error Resume Next

'Create message and configuration objects
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

'Appluy settings to the configuration object
With Flds
	' Specify the authentication mechanism to basic (clear-text) authentication. 
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = cdoBasic
	' The username for authenticating to an SMTP server
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")[/URL] = ""
	' The password used to authenticate to an SMTP server
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = ""

	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = cdoSendUsingPort
	'Specify mail server
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "mail.carmnet.com"
	'Specify the timeout in seconds
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 10

	' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25)
	'.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25 
	'Use SSL for the connection (False or True)
	'.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")[/URL] = False

	.Update
End With

Dim sMsg 
Dim sTo 
Dim sCC
Dim sFrom 
Dim sSubject 
Dim sTextBody 

sTo = "rapeek@carmnet.com"

sFrom = "rapeek@carmnet.com"
sSubject = strrcdcnt
sTextBody = "Insert here your plain body text"

'Apply the settings to the message object
With iMsg
	Set .Configuration = iConf
	.To = sTo
	.From = sFrom
	If strCC <> "" Then 
		.CC = strCC
	End If
	.Subject = sSubject
	.TextBody = sTextBody
	
	'Send message
	.Send
	
End With

' cleanup mail objects
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
 
The difference is that, in the longer code, it is connecting directly to the SMTP service on a machine named mail.carmnet.com and in the first example in the link is trying to use the SMTP service on the web server.
 
So they are just like 2 different post offices. You just drop your mail to them and they send it to designated address, right?
By the way, I found my email in inetpub\mailroot\queue with the 1st code. Is that mean the web server is not activate to send out mail?

Thanks.
 
By the way, I found my email in inetpub\mailroot\queue with the 1st code. Is that mean the web server is not activate to send out mail?

that usually means there is something wrong with the setup and not with the code...check your SMTP server settings...

-DNG
 
IIS has not only the but also an FTP service and a SMTP service. So if the STMP service isn't running or isn't configured correctly then you'll end up with messages stuck in \queue and \badmail folders.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top