CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 The example

Print topic Send  topic

Author Message
Lars
Posted: 10/17/2003, 4:13 AM

I totally agree with BB, I can see that the article has been viewed 4400 times which means that we actually, look at the articles to learn CC(S)
I think that having good tutorials is imperative for an even bigger success for codecharge, after all they claim that this is also for non-programmers
Another way of making even better tutorials, and which is both better an easier is to use grap the tutorial and present this in Flash.. like this:
http://www.softcapital.com/support/cromeless/video.htm

I could really use this, since in many of the tutorials small details are forgotten, that makes it impossible to complete the tutorial..

BTW.. why I am at it.. I could really use an example for CSS as how to send an email when a password is forgotten

Cheers,
Hamilton
Posted: 10/17/2003, 4:50 AM

Add the following function to the forgotpwd_events.asp page - preferably somewhere in the middle of the page.

Function SendEmail(vSenderEmail, vRecipientEmail, vSubjectLine, vBodyHTML)
On Error Resume Next
Dim sHTML
Dim myMail

SendEmail = False

Set myMail = CreateObject("CDONTS.NewMail")
If myMail Is Nothing Then Exit Function

sHTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & vbCrLf
sHTML = sHTML & "<HTML>"
sHTML = sHTML & "<head>"
sHTML = sHTML & "<meta http-equiv=""Content-Type"""
sHTML = sHTML & "content=""text/HTML; charset=iso-8859-1"">"
sHTML = sHTML & "<title>Email Notification</title>"
sHTML = sHTML & "</head>"
sHTML = sHTML & "<body>"
sHTML = sHTML & "<table border=""0"" width=""95%"" cellspacing=""1"">"
sHTML = sHTML & "<tr><td bgcolor=""White"" width=""100%""><font face=""Verdana"" size=""1"" color=""Black"">" & vBodyHTML & "</td></tr>"
sHTML = sHTML & "</table>"
sHTML = sHTML & "</body>"
sHTML = sHTML & "</HTML>"

myMail.From = vSenderEmail
myMail.To = vRecipientEmail
myMail.Subject = vSubjectLine
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.Body = sHTML
myMail.Send
If NOT myMail Is Nothing Then Set myMail = Nothing
If Err.Number = 0 Then SendEMail = True
End Function



Next, click on your submit button, go to the events tab and click 'Add Code' to the Server--OnClick event.

This is where you'll place the code to retrieve the values (the forgotten password) and call the SendEmail() function.

When the user hits submit, you'll need to perform a look-up of their email address. From within CCS, hit F1 to get the CCS help, then traverse the tree to
-->Examples and Techniques
------>Working With Databases
------------->Retrieve Multiple Field Values From A Database

Here is the code from the CCS help file.

'**********
Dim SQL
Dim RecordSet
Dim UserId
Dim UserName
Dim WorkPhone

' Read user_id from URL
UserId = CCGetFromGet("user_id", 0)

If UserID > 0 then
SQL = "SELECT emp_name, phone_work FROM employees WHERE emp_id="&UserId
' Open the recordser
Set RecordSet = DBConnection1.Execute(SQL)
If DBConnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
UserName = CCGetValue(RecordSet, "emp_name")
WorkPhone = CCGetValue(RecordSet, "phone_work")
End if
' Close the recordser
RecordSet.Close
Set RecordSet = Nothing
Else
Print "SQL Execution Failed."
DBConnection1.Errors.Clear
End If

' Show a label value
UserInfo.Value = UserName & ", phone: "&WorkPhone
Else
UserInfo.Visible = False
End if
'**********

You need to take the code from this examle and modify it for your particular table structure and DBConnection name. The example uses a DBConnection called "DBConnection1" which you'll likely have to change. (Check your applications settings 'Connections' tab for the name of your connection. CCS places a DB in front of whatever connection name you used..)
Change the DBConnection name within the function accordingly.

After retrieving the recordset containing the users password and login as well as any other fields you require, you create the string that you'll send when you call the SendEmail() function.

For example;

'**********
Dim SQL
Dim RecordSet
Dim UserId
Dim UserName
Dim WorkPhone
'MODIFICATIONS TO SEND EMAIL BEGINS
Dim sRecipientEmail
Dim sSendersEmail
Dim sTitleOfEmail
Dim sHTML
sHTML = ""
sRecipientEmail = ""
sSendersEmail = "<YOUR EMAIL ADDRESS>"
sTitleOfEmail = "<TITLE FOR THE EMAIL>"
'MODIFICATIONS TO SEND EMAIL ENDS

' Read user_id from URL
UserId = CCGetFromGet("user_id", 0)

If UserID > 0 then
SQL = "SELECT emp_name, phone_work FROM employees WHERE emp_id="&UserId
' Open the recordser
Set RecordSet = DBConnection1.Execute(SQL)
If DBConnection1.Errors.Count = 0 Then
If NOT RecordSet.EOF then
UserName = CCGetValue(RecordSet, "user_name")
sRecipientEmail = CCGetValue(RecordSet, "email")
End if
' Close the recordser
RecordSet.Close
Set RecordSet = Nothing
Else
Print "SQL Execution Failed."
DBConnection1.Errors.Clear
End If

' Show a label value
'DEL UserInfo.Value = UserName & ", phone: "&WorkPhone
'MODIFICATIONS TO SEND EMAIL BEGINS
If Len(UserName) > 0 Then
sHTML = sHTML & "To: " & UserName & "<BR>"
sHTML = sHTML & "Your user id and password have been provided below;"
sHTML = sHTML & "<etc., etc.,>"

Call SendEmail(sSendersEmail, sRecipientEmail, sTitleOfEmail, sHTML)
End If
'MODIFICATIONS TO SEND EMAIL ENDS
Else
UserInfo.Visible = False
End if
'**********

Lars
Posted: 10/17/2003, 9:46 AM

Hello Hamilton
Thanks for your in-depth description.
In your first sentence:
"Add the following function to the forgotpwd_events.asp page - preferably somewhere in the middle of the page"

It seems to me that you are referring to an allready existing page, since you say i should add this to the middle of the page. Now - is there a tutorial or something like I have missed?? If so, can you redirect me to this ?
Cheers



   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.