CodeCharge Studio
search Register Login  

Visual PHP Web Development

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

YesSoftware Forums -> Archive -> GotoCode Archive

 CDONTS After Insert

Print topic Send  topic

Author Message
Sean
Posted: 07/14/2003, 9:52 AM

Does anyone have a code snipet using CDONTS for After Insert?

I want to be able to send an email after I update or create a new record. Just an exaple to get me going would be nice.

I am using ASP 3.0 w/templates and CCS 2.1 using an Access 2000 database.

Thanks for the help.
Sean
Posted: 07/14/2003, 9:54 AM

I am using CDONTS because I could not get ASPEmail to work properly so I could use the Code Charge example. If anyone has any info on getting ASPEmail to work properly with IIS in Windows 2000, it would be much appreciated.
GreggB
Posted: 07/14/2003, 10:05 AM

Here is the Basic code:

With CreateObject("CDONTS.NewMail")
.From = "From Email address"
.To = "To Email address"
.Cc = "Cc Email addresses"
.Subject = "Your Subject"
.Body = "Your Body"
.BodyFormat = 0
.MailFormat = 0
.Send
End With


If you search this site for CDONTS you will many examples

GreggB
Sean
Posted: 07/14/2003, 10:57 AM

Thanks for the code. It works as is, but how do I take it a step further? I want to include in the body the variables that were added to the record, such as ProductName?

FYI. I did do a search first, but I didn't find much on the example side for using CDONTS. I looked in Tips and Community, but didn't find an example that would help me.

Thanks again.
GreggB
Posted: 07/14/2003, 11:38 AM

This code is an example of getting email addresses and name from a database and using the variables from a Form.




DIM email_to, email_from, email_to_name

Look UP Email Address for TO:
email_to = CCDLookUp("email", "employees", "employee_id=" &
CCToSQL(tasks.email_to.Value, "Integer"), DBisoperations)

Look UP Email Address for FROM:
email_from = CCDLookUp("email", "employees", "employee_id=" & CCToSQL(tasks.eamil_from.Value, "Integer"), DBisoperations)

Look UP NAME for Email TO Address:
email_to_name + CCDLookUp("employee_name", "employees", "employee_id=" & CCToSQL(tasks.email_to_name, "Integer"), DBisoperations)

With CreateObject("CDONTS.NewMail")

.From = email_to

.To = email_from

.Subject = "Test using varibles from form for email body"

.Body = "Dear" & email_to_name _
& form_name.variable.Value

.BodyFormat = 0
.MailFormat = 0
.Send
End With


The following address is example of working code retrieving variables and using them in html output for email.

(http://gotocode.com/disc_viewt.asp?mid=19355&s_topic=CDONTS&) I posted.


GreggB
Sean
Posted: 07/14/2003, 12:05 PM

Gregg, thanks for all your help.

I must be doing something wrong because I keep getting errors (variables undefined).

I am very new at this and am not a programmer. The code you gave me earlier will send an email to my specified distribution list when a new entry is created, but I want to pass the newly entered data in the body of the email. I basically just need to find out how to pass the variables that I already have into the body of the email. Please be patient with me. I am trying to learn this stuff, but am a Network Admin and not an ASP programmer.

Thanks again for the help.
Sean
Posted: 07/14/2003, 1:04 PM

Ok, I got it figured out using the Send Email action, but is there a way to do a line break so I can use formatting? My code looks like this.

'Send Email @19-066942CA
With CreateObject("CDONTS.NewMail")
.From = "Example"
.To = "sbrown@domain.com"
.Subject = tblExample.ProductName.Text
.Body = "A new entry: " & tblExample.ProductName.Text & " " & tblExample.CategoryID.Text & "has been added in the Example database."
.BodyFormat = 1
.MailFormat = 0
.Send
End With
'End Send Email
D. Johnson
Posted: 07/14/2003, 7:05 PM

OOPS! I put this in a new thread. Oh well......

You can separate lines like this
.Body = "Name: " & strName & vbCrLf _
& "Address: " & strAddress & vbCrLf _
& "City: " & strCity & vbCrLf _
etc.
etc.
Sean
Posted: 07/15/2003, 6:48 AM

THANKS! That's exactly what I was looking for. It works perfectly.

   


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.