CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Send Email on AfterInsert Event.

Print topic Send  topic

Author Message
Rlane313

Posts: 7
Posted: 10/23/2007, 6:25 AM

Hello,
I have a customer feedback form that I want to automatically send out an
email to managers with the content of the feedback submission in the body of
the email. The web hosting company only has cdosys available. This site is
in ASP. I am using CodeCharge Studio version 2.3.2.28. I have tried the
built-in send mail and I cannot get it to work. So I created a custom code
to accomplish this.

My goal:
the message works fine here but I want to add the content of the form data
that was just submitted to the database into the body of the email message.
I don't know how to access that from the codecharge form.

This is what I have so far and it works well.

Function Feedback_AfterInsert() 'Feedback_AfterInsert @4-62266B6B

'Custom Code @24-73254650
' -------------------------
dim sEmail, sMessage
dim oCdoMail, oCdoConf, sConfURL


Set oCdoMail = Server.CreateObject("CDO.Message")
Set oCdoConf = Server.CreateObject("CDO.Configuration")
sEmail = "managersemail@formsite.com"
sMessage = "View details at: http://www.formsite.com/Admin/AdmFeedback.asp";

sConfURL = "http://schemas.microsoft.com/cdo/configuration/"

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

with oCdoMail
.From = "performancereport@formsite.com"
.To = sEmail
.cc = "myemail@formsite.com"
.Subject = "New Guest Performance Report"
.TextBody = sMessage
.HTMLBody = sMessage
.Configuration = oCdoConf
.Send
end with

Set oCdoConf = Nothing
Set oCdoMail = Nothing
' -------------------------
'End Custom Code

End Function 'Close Feedback_AfterInsert @4-54C34B28
View profile  Send private message
Bubba

Posts: 33
Posted: 10/23/2007, 8:14 PM

It is fairly straight forward, but you are best to send as HTML email, thus you will need to use some simple HTML code:

Body = "<b>Customer Contact Details:" & "<br>" & "Title: </b>" & FormName.Title.Value & "<br><b>" _
& "First Name: </b>" & FormName.FirstName.Value

etc. etc

FormName is your formname, and FirstName.Value a control (like a text box) on your form.

The <b> and <br> etc are HTML (for bold and line break)
View profile  Send private message
Rlane313

Posts: 7
Posted: 10/24/2007, 3:10 AM

Thank you very much Bubba! That worked perfectly.

Randy
View profile  Send private message

Add new topic Subscribe to topic   


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

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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