Link to home
Start Free TrialLog in
Avatar of Lord2FLI

asked on

E-mail on Submit, not Page Load (vbscript)

I'm using the below code to to send e-mails and it works fine except it sends when I load the page and I really need it to send it when users click the submit button.  I tried the mailto: process in the form action, but my users don't have e-mail on their desktops and that looks for a default e-mail program to send the e-mail so it's not a solution.  Any help would be appreciated.

Dim sName, sEmail, sMessage
Dim oCdoMail, oCdoConf, sConfURL

sName = ""

sMessage = "An Request is awaiting your review."

Set oCdoMail = Server.CreateObject("CDO.Message")
Set oCdoConf = Server.CreateObject("CDO.Configuration")

sConfURL = ""

with oCdoConf
	.Fields.Item(sConfURL & "sendusing") = 2
	.Fields.Item(sConfURL & "smtpserver") = ""
	.Fields.Item(sConfURL & "smtpserverport") = 25
end with

with oCdoMail
	.From = sName
	.To = ""
	.Subject = "Test"
	.TextBody = sMessage
	.HTMLBody = sMessage
	.Configuration = oCdoConf
end with

Set oCdoConf = Nothing
Set oCdoMail = Nothing

Open in new window

Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lord2FLI


Awesome!  worked like a charm, thank you very much!
my pleasure, glad I could help :)