CDONTS

A

Andy

I have a web and database set up on our SQL server and
it's working fine. However, I'd like to add a new page
that sends form data to the database and to e-mail at the
same time. I'm using CDONTS in trying to accompish this.
The problem is I'm getting this error when submitting the
form:

Microsoft VBScript runtime error '800a0046'

Permission denied

/Production1.asp, line 108

The powers that be that control the SQL server say that
this is due to no e-mail being set up on that server. They
don't want to set it up either it sounds like because of
security concerns. They suggested that I use an external
server such as the company SMTP server for the e-mail
part.

Of course this presents a real challenge to me because how
do I route e-mail to an external server and submit to the
database at the same time? Is that even possible?
 
R

Roy Lindhardt

Andy,

I don't know if it is impossible to send to both an external email
server and a database, but I can at least give you the code to send email
through an external server.

<%@ Language=VBScript %>
<%
dim objNewMail
set objNewMail = CreateObject("CDO.Message")
dim iConf
set iConf = CreateObject("CDO.Configuration")
dim strName
dim strEmail
dim strRecip
dim strSubject
dim strMessage

strName = Trim(Request.Form("Name"))
strEmail = Trim(Request.Form("Email"))
strMessage = Trim(Request.Form("Comments"))

Select Case Request("Subject")
Case "Accommodations" strRecip="(e-mail address removed)"
Case "Dining" strRecip="(e-mail address removed)"
Case "Fitness" strRecip="(e-mail address removed)"
Case "Meetings" strRecip="(e-mail address removed)"
Case "Website" strRecip="(e-mail address removed)"
Case "Other" strRecip="(e-mail address removed)"
End Select

Select Case Request("Subject")
Case "Accommodations" strSubject="The Little America Hotel & Towers:
Accommodations Comment"
Case "Dining" strSubject="The Little America Hotel & Towers: Dining Comment"
Case "Events" strSubject="The Little America Hotel & Towers: Fitness and
Salon Comment"
Case "General" strSubject="The Little America Hotel & Towers: Meetings
Comment"
Case "Website" strSubject="The Little America Hotel & Towers: Website
Comment"
Case "Other" strSubject="The Little America Hotel & Towers: Comment"
End Select

objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/sendusing") = 2
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpserver") = "mail.sinclairoil.com"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpserverport") = 25
objNewMail.Configuration.Fields.Update
objNewMail.Subject = strSubject
objNewMail.From = "(e-mail address removed)"
objNewMail.ReplyTo = strEmail
objNewMail.To = strRecip
objNewMail.HTMLBody = "<font face='Times New Roman' size='2'>" + strMessage
+ "<br><br>From: " + strName + "<br>" + strEmail
objNewMail.Send
set objMail = Nothing
Set iConf = Nothing
Set Flds = Nothing
%>

Best of luck to ya,


Roy
 
A

Andy

Thanks I'll give it a shot.
-----Original Message-----
Andy,

I don't know if it is impossible to send to both an external email
server and a database, but I can at least give you the code to send email
through an external server.

<%@ Language=VBScript %>
<%
dim objNewMail
set objNewMail = CreateObject("CDO.Message")
dim iConf
set iConf = CreateObject("CDO.Configuration")
dim strName
dim strEmail
dim strRecip
dim strSubject
dim strMessage

strName = Trim(Request.Form("Name"))
strEmail = Trim(Request.Form("Email"))
strMessage = Trim(Request.Form("Comments"))

Select Case Request("Subject")
Case "Accommodations" strRecip="(e-mail address removed)"
Case "Dining" strRecip="(e-mail address removed)"
Case "Fitness" strRecip="(e-mail address removed)"
Case "Meetings" strRecip="(e-mail address removed)"
Case "Website" strRecip="(e-mail address removed)"
Case "Other" strRecip="(e-mail address removed)"
End Select

Select Case Request("Subject")
Case "Accommodations" strSubject="The Little America Hotel & Towers:
Accommodations Comment"
Case "Dining" strSubject="The Little America Hotel & Towers: Dining Comment"
Case "Events" strSubject="The Little America Hotel & Towers: Fitness and
Salon Comment"
Case "General" strSubject="The Little America Hotel & Towers: Meetings
Comment"
Case "Website" strSubject="The Little America Hotel & Towers: Website
Comment"
Case "Other" strSubject="The Little America Hotel & Towers: Comment"
End Select

objNewMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/confi
guration/sendusing") = 2
objNewMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/confi
guration/smtpserver") = "mail.sinclairoil.com"
objNewMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/confi
guration/smtpserverport") = 25
objNewMail.Configuration.Fields.Update
objNewMail.Subject = strSubject
objNewMail.From = "(e-mail address removed)"
objNewMail.ReplyTo = strEmail
objNewMail.To = strRecip
objNewMail.HTMLBody = "<font face='Times New Roman' size='2'>" + strMessage
+ "<br><br>From: " + strName + "<br>" + strEmail
objNewMail.Send
set objMail = Nothing
Set iConf = Nothing
Set Flds = Nothing
%>

Best of luck to ya,


Roy





.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top