473,472 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to call values frm access db and query it to send an email

46 New Member
Hi All,

Well- this question might have appeared several times on this forum- but would appreciate your reply on this:
I have a asp page, where customers login with some username and the pwd, which are stored in sql. i should be using this user name and pwd and check if it is the same as the userid and the pwd in the sql 4 table..IF so then:
display the download url which is in sql3 by querying the four tables..

These four tables are stored in MS Access.

sql1-id, name: Columns
sql2-id, email id
sql3-id, contract number, maintenance start date, maintenance exp date, download url, main email id, maintenance status,
sql4- user id, pwd, account name

So - this is the code- ihave written ,please tell me where the error is:

ONce the display of the URL is complete, then I am using CDOSYS to send an email to the email address int he sql2, for which i have written the code ..
I am getting internal server error 500...
please help in this..
-tanya


code is :

<%@ language

<% Option Explicit


'Declare Local Variables

Dim conn, strSQL
Dim strEmail,strUrl
Dim objMail, objRS
Dim strMessageBody, strDisclaimer
Dim sql1, sql2, sql3, sql4, UserName, Password
Dim ACCOUNT ID, ACCOUNT NAME, EMAIL ID
Dim CONTRACT NUMBER, MAINTENANCE_START_DATE_C, MAINTENANCE_EXPIRATION_DATE_C,downloadURL
Dim ESD Contact, MAINTENANCE_STATUS, User ID, Pwd
'End Variable Declaration

%>

<html><head><title>Posting Mail</title></head>
<body bgcolor=acqua leftmargin='1' topmargin='1'><table width='100%' height='100%' cellspacing='0' cellpadding='2'>
<tr align='left'><td height='100%' width='145' valign='top'></td><td width='555' valign='top' align='left'>

<%'get form elements and compose email

Function ReplaceSpecial(str)
If NOT IsNull(str) Then
ReplaceSpecial = Replace(str, "'", "''")
End If
End Function

'strEmail = Trim(ReplaceSpecial(Request.Form("User_Email")))

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "DSN=sql"
Set objRS = Server.CreateObject("ADODB.Recordset")


strSQL ="SELECT * FROM sql1, sql2, sql3, sql4 where sql3.User Id=Session (UserName) And Pwd=Session(Password)"
strSQL =strSQL & "And sql4.ACCOUNT NAME=sql1.ACCOUNT NAME And sql1.ACCOUNT ID=sql3.ACCOUNT ID"
strSQL =strSQL & " And sql2.EMAIL ID=sql3.ESD Contact WHERE (sql3.MAINTENANCE CONTRACT)='Y'"


objRS.open strSQL,conn

response.write strEmail

response.write strSQL
response.write objRS("sql3.download URL")

strEmail=objRS("sql3.ESD Contact")

If NOT objRS.EOF Then
'CREATE THE MESSAGE OBJECT
strUrl="http://" & objRS("sql3.download URL")


Set objMail = Server.CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.

objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.myserver.com"
objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'End remote SMTP server configuration section


objMail.Subject = "Download your software "
objMail.From = "me@myserver.com"
objMail.To = strEmail

'objMail.MailFormat = 0 'MIME Format
'objMail.BodyFormat = 0
strMessageBody = "Hi, You can download from this site <a href='" & strUrl & "' > " & strUrl & "</a>"


strMessageBody = strMessageBody & "<br><br>Thank You,"
strDisclaimer = "<br><br><p><font color='#777777' size='-1.5' face='Arial'><i>This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.</i></font>"

'objMail.Body = strMessageBody & strDisclaimer
objMail.HTMLBody= strMessageBody & strDisclaimer

objMail.Send

objRS.Close

Set objRS = Nothing

%>

<table>
<tr><td class="normal">Your request has been processed. Email address is: <%=strEmail%> Software URL is: <%=strUrl%>

</td></tr>
<tr><td class="normal"></td></tr>
<tr><td class="normal">Thank You</td></tr>
</table>
<%Else%>
<table>
<tr><td class="normal"><font size='+1' color='Red'><b>Your request could not be processed. You will need to check the information that was submitted </b></font></td></tr>
</table>
<%End If%>

</td>
</tr>
</table>
<hr>

</body>
</html>
Jun 4 '07 #1
1 2274
Vodoappaseger
1 New Member
This is without doubt the most awesome most informative website I've seen yet,I am glad I discovered bytes.com

here are a few words of chaos:
Shame and shame!
Oct 3 '10 #2

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

Similar topics

2
by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and processes the sql query. What am I doing wrong??? ...
7
by: Malcolm Cook | last post by:
Hi, I've created and installed a custom UDF to populate my combobox, and have defined it per :...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
4
by: bhieb | last post by:
Alright this is a new one to me. I have linked a table using ODBC to our AS400. When I either open it directly or query it I get the incorrect values for several fields. For example the query on...
1
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I...
3
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the...
1
by: jerry.ranch | last post by:
I collect information from my clients with an xls file I import the xls data into my access table. I don't have them put info directly into Access, because, despite the drop downs I have for...
10
by: tlyczko | last post by:
Hello, We have Access databases (backends) that will eventually be consolidated into a SQL Server database, to facilitate data reporting, analysis, etc. Some queries in one Access database...
2
by: Fabio Mastria | last post by:
My application has to call a webpage with some hidden field, fill their values with some parameters and then call the submit to the form which has the action property set to a page of another web...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.