473,805 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting SQL Email, using ASP to email using database

9 New Member
The low down:
Local Web Server on Windows 2003
Local SQL Server on Windows 2003
Hosting dynamic website tied to inhouse Access Application

Ok, basically, how it is set up, people can login to our website and enter data (insert record), on our end, we have an Access application where we can play with the data that was entered via the website. Currently, we do not have either server set up as a Mail server.

What we need to be able to do:
When a customer enters data on our website, their supervisor, and about 2-3 other people related to the transaction need to be emailed to be notified that an order was submitted. So how do I code that? On the page with the Insert Record? OR after Insert Record redirect them to another page that sends the mail out?

Also, it needs to dynamically email people, so I can't just put in john@doe.com for a value, I'd need to put in something like <%=(megalist.Fi elds.Item("emai l").Value)%>

Which server do I enable the mail?

I was reading about SQL Mail etc, which would be good since we do mass emails to clients weekly, but I have no idea how to set that up and I look crossed eyed at any tutorial.

Do I want to set up theSQL server to also be a Mail Server that way we can use the SQL database to email as well as data entered from the website? But then again, the website points to the Web Server which pulls data off the SQL server (so unless the Web Server is a mail server, nothing will be sent, am I right?)

*sigh*

I know very little about SQL and I'm being asked to impliment this and I am 100% confused. I'm a graphics artist not a programmer! LOL

Thanks in advance to anyone who can/will help me.
Aug 27 '07 #1
13 3828
bakpao
21 New Member
Assuming you have the following pages:
Order_Form.asp = where user enters the items they want to order
Order_Submit.as p = where you are updating the database

The mail sending should be done in Order_Submit.as p. There is no need to forward the user to another special page which sends email.

To send email, try searching this site or Google for the terms: ASP, CDO and mail sending.

For the server, you need to have a dedicated SMTP server or enable your Windows 2003 server to handle email. You don't send the email from the SQL Server application.

If you think it's too hard, you can just let your supervisor know so he can help you. :)
Aug 27 '07 #2
vmethod
9 New Member
Actually, one the page where they enter data, it's just a single page set up with an Insert Record code. And that's what I meant about the send email from a second page (I think we are thinking the same, just didn't come out the same). I guess in other words what I am thinking, is do Insert Record on page1.asp then have it go to page2.asp and it doesn't necessarily need to carry over the information, but have it email from page2.asp using a Recordset (so I can grab the supervisor, client results manager, real estate agents, etc) from that to use in the code.

Ok, so set up the SMTP on the web server then? I actually looked but did not see a SMTP Service. There was a virtual mail server under the server configuration, but that was all I saw...

this is going to be a fun adventure... *sarcastic*

Assuming you have the following pages:
Order_Form.asp = where user enters the items they want to order
Order_Submit.as p = where you are updating the database

The mail sending should be done in Order_Submit.as p. There is no need to forward the user to another special page which sends email.

To send email, try searching this site or Google for the terms: ASP, CDO and mail sending.

For the server, you need to have a dedicated SMTP server or enable your Windows 2003 server to handle email. You don't send the email from the SQL Server application.

If you think it's too hard, you can just let your supervisor know so he can help you. :)
Aug 28 '07 #3
bakpao
21 New Member
I think it's better if you send the email straight after the insert instead of forwarding it to another page. But that's just my preference.

I never set up the SMTP myself but if you run IIS you may be able to find "Default SMTP Virtual Server" under the computer/server. It could be the starting point for you.

You can test whether or not your server is SMTP capable by running this in command prompt:
Expand|Select|Wrap|Line Numbers
  1. telnet whateveryourhostnameis 25
  2.  
For example:
Expand|Select|Wrap|Line Numbers
  1. telnet smtp.gmail.com 25
  2.  
If it works, it will show you some text about the SMTP server. Just type "quit" to exit.

You can then plug in that server name in your CDO code to be able to send email.
Aug 28 '07 #4
vmethod
9 New Member
That's just the thing, I don't know how to send it on the same page as the insert record page :(

I'm still researching as much as possible, but he really wants this ASaP

On the webserver, it has a Default SMTP Virtual Server set up but it is set to the default domain which is our local domain. Do I need to add another domain that reflects our domain name for the actual web site?
Aug 28 '07 #5
markrawlingson
346 Recognized Expert Contributor
You'll need an API installed to handle this. The company I work for currently uses ASPMail. I would suggest your first course of action to be asking a co-worker or your supervisor/superior if there is a mailing object installed on the server and if so - what is it?

If it happens to be ASPMail - Below is the code that we use (for privacy issues i've modified some of the content of course) However if it's not ASPMail - let us know what it is - myself, or someone else, will point you in the right direction.

Expand|Select|Wrap|Line Numbers
  1.  
  2.      sSQL = "SELECT STATEMENT"            
  3.      Set rsEmail = CreateObject("ADODB.RecordSet")
  4.      rsEmail.Open sSQL, Application.StaticObjects("oConnSQL"), adOpenReadOnly, adLockOptimistic, adCmdText
  5.      Set oMailer = CreateObject("SMTPsvg.Mailer")
  6.      oMailer.RemoteHost = "whatever.something.com" <-- your mail host
  7.      oMailer.FromAddress = "admin@somedomain.com"
  8.      oMailer.FromName = "Administrator"
  9.      oMailer.AddRecipient Request.Form("sFirstName") & " " & Request.Form("sLastName") , Request.Form("sEmailAddress")
  10.      If NOT IsNull( rsEmail("sCCEmail") ) Then
  11.           oMailer.AddCC "Registrar",rsEmail("sCCEmail")
  12.      End If
  13.      If NOT IsNull( rsEmail("sBCCEmail") ) Then
  14.           oMailer.AddBCC "Registrar",rsEmail("sBCCEmail")
  15.      End If
  16.      oMailer.Subject = rsEmail("sSubject")
  17.      oMailer.ContentType = "text/html"
  18.      oMailer.BodyText = rsEmail("sHTML")
  19.      oMailer.SendMail
  20.      Set oMailer = Nothing
  21.      rsEmail.Close
  22.      Set rsEmail = nothing
  23.  
Where and when you send the email is entirely your decision and it completely depends on the scenario. For this particular scenario you have to consider that you wouldn't want to send an email to anyone until you know that 1) the user has filled in the form and submitted it... 2) the form contained no errors and the submission was successful... and 3) your database accepted the information and there is now a record in your database pertaining to the individual who filled out the form.

So Because of that reason, I wouldn't do it directly after your insert statement

rs.AddNew
rs("field1") = whatever
rs("field1") = whatever
rs("field1") = whatever
rs("field1") = whatever
rs("field1") = whatever
rs.Update

'place mailing code here, directly after the insert statement.
Aug 28 '07 #6
vmethod
9 New Member
Unfortunately, I do it all here. I'm "IT" (hehe sorry gotta have some humor). There is no mail set up on either server. I attempted in setting up smarthost on the virtual smtp server on the web server. Not sure if I did it correctly or not, I left the outbound to default anonymous authentication, but I entered the SMTP mail server address (through godaddy) under Advanced options. Again, not sure if that will work.

But really, I'm expected to do everything, server, network, pc, graphics, web design lol. It's a bit over whelming at times, and right now I think my head is in love with my desk because it's been pounding it all day. (Did not intentionally mean for that to be an innuendo LOL)

But I do want it to send the email right after the user clicks Update (or Insert) otherwise I don't see how else it would be triggered to pull the information they entered. (I'm guessing a Request.Form of some sort is going to play a role in this)

Thank you all for all your help so far, I'm sure I must be a pain knowing nothing about ASP and mixing it with everything. But I do what I can.
Aug 28 '07 #7
markrawlingson
346 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
  3. Mailer.FromName = "website"
  4. Mailer.FromAddress= "user@yourdomain.com"
  5. Mailer.RemoteHost = "localhost"
  6. Mailer.AddRecipient "Name", "name@yourdomain.com"
  7. Mailer.AddExtraHeader "X-MimeOLE:Produced yourdomain.com"
  8. Mailer.Subject = "Form Submission"
  9. Mailer.BodyText = "Enter the body of the message here."
  10. if Mailer.SendMail then
  11.   Response.Write "Form information submitted..."
  12. else
  13.   Response.Write "Mail send failure. Error was " & Mailer.Response
  14. end if
  15. set Mailer = Nothing
  16. %>
  17.  
Do this for me...

1) Make sure SMTP is setup on your server properly.
2) Download the free version of ASPMail from Server Objects Inc. http://www.serverobjec ts.com/products.htm
3) Install it and follow the installation/configuration instructions listed at this address - http://www.serverobjec ts.com/comp/Aspmail4.htm
4) Create a new file and paste the above code into it.
5) Clean up the code, replace the values with your own email address, name, etc
6) save the file as something like mailer.asp
7) run the file and see if it works - if it doesn't it should spit out some sort of error at you. Show that error if you get one.

I've never used "localhost" as the remote host, but it should work. I don't see why it wouldn't!
Aug 28 '07 #8
vmethod
9 New Member
Ok I ended up with this error:

Mail send failure. Error was This evaluation component has expired.

obviously because the trial expired... hmmm...

I attempted to even use the code:

<%
Set myMail=CreateOb ject("CDO.Messa ge")
myMail.Subject= "Sending email with CDO"
myMail.From="my mail@mydomain.c om"
myMail.To="v.w@ myemail.com"
myMail.TextBody ="This is a message."
myMail.Send
set myMail=nothing
%>

knowing I attempt to set up the smarthost for the virtual smtp server... it didn't give me an error, but I also did not receive an email. Suggestions?
Aug 28 '07 #9
markrawlingson
346 Recognized Expert Contributor
Boo. Sorry i didn't realize they'd limited their trial version like that.

Hmm, so you tried CDOSYS/CDONTS - that should work.

If you didn't get an error, the email probably at least tried to get sent.

You didn't use that EXACT code above did you? Because you'll obviously have to change the parameters to a real email address.

Try putting an if/else statement in there to see if it does anything... it can often help to troubleshoot but it looks like you're on the right path.

Try putting this in place of the myMail.Send portion of the code you supplied above.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. if myMail.Send Then
  3. response.write "the mail was sent"
  4. else
  5. response.write "the mail was not sent"
  6. end if
  7. %>
  8.  
Aug 28 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1860
by: sumdumgaitu | last post by:
I'm using the following code for a login page in PHP. Everything works OK until someone else logs in from the same browser. As best I can tell $mail, $password, and $user_id are not getting updated in the session. I tried doing session_start(); session_destroy();
6
5498
by: Nathan Sokalski | last post by:
I recently downloaded and installed (hopefully correctly) MSDE 2000 Release A. I previously, and still do, have the version of IIS that comes with XP Professional installed on my computer. I wanted MSDE 2000 Release A so that I could do database access using ASP from my websites, which are on my computer. When I went to my first test website, I recieved the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers...
0
2332
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company 1&1 with only limited server configuration via a web based control panel. My query relates to the ASP security model and how it relates to FrontPage options for setting file access on a database file. If you know of any online documentation...
1
7076
by: Bob | last post by:
I used Enterprise Manager to change the data type of one table column from one thing to another. When I attempted to save the change, I was warned that "one or more existing columns have ANSI_PADDING 'off' and will be re-created with ANSI_PADDING 'on'". I didn't expect to see this message. I verified that ANSI_PADDING is 'off' at the database level by running the following statement: SELECT DATABASEPROPERTYEX('database',...
18
18450
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
3
8321
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There are a couple of people selling components... but that is not really an option for me... So, I took the plunge and modified the "WebUIValidation.js" file to make it happen... After tracing through file, I figure it out. It was actually pretty...
4
1174
by: Phil Campaigne | last post by:
Hello, I originally installed postgresql as root user and now I am setting up a development environment with cvs and a java ide and tomcat. I have everything with the exception of postgresql integreted using a non-root user. THe process I am using is to logon as postges and start the database and do queries from the command line using psql. Then I logoff and logon as phil and start tomcat and my java ide. 1.Is there a better way to...
1
6513
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
3
20851
by: lsmith | last post by:
Dear group, I am the new volunteer coordinator for a non-profit organization in Tucson, AZ. One of my main focuses is to develop our own volunteer pool using either MS Access 2002 or Excel spreadsheets. I've used this software in previous positions and was very comfortable with the software but I'm a bit of a novice in setting up databases. However,I learn quickly. I am looking for something like an Access database template that I can...
6
10077
by: metaperl | last post by:
I would like to check the setting of this variable in our MS-SQL 2000 database. Also, is there info on what the default value of this variable is?
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.