Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2002, 12:30 AM   PM User | #1
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Automated Email Response on Send Mail

Hi,

i am using an asp script to receive the emails of subscribers.

Do you know of any script that, on receipt of an email automatically sends a reply (a preset html email), including 'Dear Name,' (if the email is name@domain.com) where specified -
maybe with the [NAME] tag?

all comments are greatly appreciated.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 07-24-2002, 06:51 AM   PM User | #2
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
You mean an auto-responder type thing.
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 07-24-2002, 07:56 AM   PM User | #3
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Correct.

If for example a user submits his email (hisname@hisdomain.com) to orders@mydomain.com he receives an automated reply (a custom html email) in the form of:

Dear Hisname,

etc.


if the emails is sent to apples@mydomain.com, Hisname would receive apple.html, write to oranges@mydomain.com and you would receive oranges.html.


is this something that has been done before (without the oranges and apples maybe ).

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 07-24-2002, 10:18 AM   PM User | #4
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Ok lol, I see hmm... Well I'm only new to asp but I imagine that it would got a little like:

Code:
<html>
<head>
</head>
<body>
<% if request.QueryString("domain") = "apples" then
autoresponse = "apples"

else if request.QueryString("domain")  = "oranges" then
autoresponse = "oranges"

dim EmailText
EmailText = "Dear & hisname &" 
dim SendEmail
SendEmail = autoresponse
dim EmailFrom
EmailFrom = " & autoresponse & @mydomain.com"
dim myMail

If SendEmail = autoresponse then
    Set myMail = CreateObject("CDONTS.NewMail") 
		myMail.From = EmailFrom		
		myMail.To = Request.Form("FruitForm") 
		myMail.Subject = autoresponse
		
        myMail.Body = EmailText
		myMail.Send
		Set myMail = Nothing
end if		
end if
end if %>
</body>
</html>
__________________
Omnis mico antequam dominus Spookster!

Last edited by Mhtml; 07-24-2002 at 11:22 AM..
Mhtml is offline   Reply With Quote
Old 07-24-2002, 06:19 PM   PM User | #5
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally posted by Mhtml
Code:
<html>
<head>
</head>
<body>
<% if request.QueryString("domain") = "apples" then
autoresponse = "apples"

else if request.QueryString("domain")  = "oranges" then
autoresponse = "oranges"

dim EmailText
EmailText = "Dear " & hisname 
dim SendEmail
SendEmail = autoresponse
dim EmailFrom
EmailFrom = autoresponse & "@mydomain.com"
dim myMail

If SendEmail = autoresponse then
    Set myMail = CreateObject("CDONTS.NewMail") 
		myMail.From = EmailFrom		
		myMail.To = Request.Form("FruitForm") 
		myMail.Subject = autoresponse
		
        myMail.Body = EmailText
		myMail.Send
		Set myMail = Nothing
end if		
end if
end if %>
</body>
</html>
[/B]
I tweaked it a tad. And fixed some syntax errors.
oracleguy is offline   Reply With Quote
Old 07-25-2002, 01:39 AM   PM User | #6
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
well I feel a little more confused, but I guess it's a very good sign.

On my site a visitor has the option to order each product by simply imputing their email address. Each submit form is run by an asp script I have included at the end of this post.

My question is how can I integrate what you posted with this script, or can I customise the script I am currently using to send an automated email to the submitter?

DHTMLHELP



<%
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True

'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user


'----------------- Place your e-mail address in the following sting ----------------------------------

strMyEmailAddress = "sales@domain.com"

'----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------

strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail

'----------- Place Blind Copy e-mail address's in the following sting, separated by ; --------------

strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail

'-----------------------------------------------------------------------------------------------------


'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")


'Initialse strBody string with the body of the e-mail
strBody = "<h2>Test Header</h2>"
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress


'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then

'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If


'Send the e-mail

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = "<" & strReturnEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the subject of the e-mail
objCDOMail.Subject = "Test Title"

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Test</title>

</head>


<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099" alink="#FF0000">
<br>

</body>


</html>
dhtmlhelp is offline   Reply With Quote
Old 07-25-2002, 09:35 PM   PM User | #7
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Hmmm, doesn't that script work?
oracleguy is offline   Reply With Quote
Old 07-25-2002, 10:27 PM   PM User | #8
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi Oracleguy,

it does work but it doesn't do everything I would like it to do.

The script I have posted sends me an email with the email address of the person requesting the product and the item desired.

What i would also like the script to do is automatically send a reply to the submitter with details on how to complete the transaction; this without having to setup an autoresponder.

Is this possible.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 07-26-2002, 05:32 AM   PM User | #9
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
I'll have a go at combining them but I can't promise anything because as I said before I've only been learning for a week.
__________________
Omnis mico antequam dominus Spookster!

Last edited by Mhtml; 07-26-2002 at 05:53 AM..
Mhtml is offline   Reply With Quote
Old 07-26-2002, 06:24 AM   PM User | #10
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
But from what I can see it would go a little like this:

Code:
<% 
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser 
Response.Buffer = True 

'Dimension variables 
Dim strBody 'Holds the body of the e-mail 
Dim objCDOMail 'Holds the mail server object 
Dim strMyEmailAddress 'Holds your e-mail address 
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail 
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail 
Dim strReturnEmailAddress 'Holds the return e-mail address of the user 
Dim strAutoEmailAddress 'Holds e-mail address of the user for Auto Responder

'----------------- Place your e-mail address in the following sting ---------------------------------- 

strMyEmailAddress = "sales@domain.com" 

'----------- Place Carbon Copy e-mail address's in the following sting, separated by ; -------------- 

strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail 

'----------- Place Blind Copy e-mail address's in the following sting, separated by ; -------------- 

strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail 

'----------------------------------------------------------------------------------------------------- 


'Read in the users e-mail address 
strReturnEmailAddress = Request.Form("email") 


'Initialse strBody string with the body of the e-mail 
strBody = "<h2>Test Header</h2>" 
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress 


'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected 
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then 

'Set the return e-mail address to your own 
strReturnEmailAddress = strMyEmailAddress 
End If 

'---------------------------------Auto Response Information Added by Mhtml-------------------------
'Set the users e-mail address
strAutoEmailAddress = strReturnEmailAddress

'set auto response body
strAutoBody = "Thank you for you order.<br><font color=(ff0000)>This is an automated response please do not reply to this e-mail</font>"
'----------------------------------------------END AUTO RESPONSE---------------------------------

'Create the e-mail server object 
Set objCDOMail = Server.CreateObject("CDONTS.NewMail") 

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent) 
objCDOMail.From = "<" & strReturnEmailAddress & ">" 

'Who the e-mail is sent to 
objCDOMail.To = strMyEmailAddress 

'Who the carbon copies are sent to 
objCDOMail.Cc = strCCEmailAddress 

'Who the blind copies are sent to 
objCDOMail.Bcc = strBCCEmailAddress 

'Set the e-mail body format (0=HTML 1=Text) 
objCDOMail.BodyFormat = 0 

'Set the subject of the e-mail 
objCDOMail.Subject = "Test Title" 

'Set the main body of the e-mail 
objCDOMail.Body = strBody 

'Importance of the e-mail (0=Low, 1=Normal, 2=High) 
objCDOMail.Importance = 1 

'Send the e-mail 
objCDOMail.Send 

'Close the server object 
Set objCDOMail = Nothing 

'-------------------------------------------------------AUTO RESPONDER ADDED BY Mhtml------------

'Create the e-mail server object 
Set objCDOMail = Server.CreateObject("CDONTS.NewMail") 

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent) 
objCDOMail.From = "<" & strMyEmailAddress & ">" 

'Who the e-mail is sent to 
objCDOMail.To = strAutoEmailAddress 


'Set the e-mail body format (0=HTML 1=Text) 
objCDOMail.BodyFormat = 0 

'Set the subject of the e-mail 
objCDOMail.Subject = "Auto Response to order submission" 

'Set the main body of the e-mail 
objCDOMail.Body = strAutoBody 

'Importance of the e-mail (0=Low, 1=Normal, 2=High) 
objCDOMail.Importance = 1 

'Send the e-mail 
objCDOMail.Send 

'Close the server object 
Set objCDOMail = Nothing 



%> 
<html> 
<head> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<title>Test</title> 

</head> 


<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099" alink="#FF0000"> 
<br> 

</body> 


</html>
I think this should work.
PS: You can see where I have put in the exrta code, you can remove the added by Mhtml ifyou want, I just put it there so that you can see where I did stuff.
__________________
Omnis mico antequam dominus Spookster!

Last edited by Mhtml; 07-26-2002 at 06:27 AM..
Mhtml is offline   Reply With Quote
Old 07-26-2002, 01:31 PM   PM User | #11
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Hi Mhtml,

thank you so much, i will test it immediately. If oracleguy you get a chance to read this post could you doublecheck Mhtml's work?


thank you,

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 07-26-2002, 06:05 PM   PM User | #12
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
It should work for ya. I didn't see anything wrong with it.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-28-2002, 09:08 PM   PM User | #13
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Unhappy Not Working

Hi,

it doesn't seem to work, I get the following message:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'strAutoBody'

/asp/test.asp, line 50


DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Old 07-29-2002, 08:32 AM   PM User | #14
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
oh ok, I see the prob. I didn't declare the variable strAutoBody.

I have fixed it.
Code:
<% 
'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser 
Response.Buffer = True 

'Dimension variables 
Dim strBody 'Holds the body of the e-mail 
Dim objCDOMail 'Holds the mail server object 
Dim strMyEmailAddress 'Holds your e-mail address 
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail 
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail 
Dim strReturnEmailAddress 'Holds the return e-mail address of the user 
Dim strAutoEmailAddress 'Holds e-mail address of the user for Auto Responder
Dim strAutoBody 'Body for Auto Response
'----------------- Place your e-mail address in the following sting ---------------------------------- 

strMyEmailAddress = "sales@domain.com" 

'----------- Place Carbon Copy e-mail address's in the following sting, separated by ; -------------- 

strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail 

'----------- Place Blind Copy e-mail address's in the following sting, separated by ; -------------- 

strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail 

'----------------------------------------------------------------------------------------------------- 


'Read in the users e-mail address 
strReturnEmailAddress = Request.Form("email") 


'Initialse strBody string with the body of the e-mail 
strBody = "<h2>Test Header</h2>" 
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress 


'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected 
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then 

'Set the return e-mail address to your own 
strReturnEmailAddress = strMyEmailAddress 
End If 

'---------------------------------Auto Response Information Added by Mhtml-------------------------
'Set the users e-mail address
strAutoEmailAddress = strReturnEmailAddress

'set auto response body
strAutoBody = "Thank you for you order.<br><font color=(ff0000)>This is an automated response please do not reply to this e-mail</font>"
'----------------------------------------------END AUTO RESPONSE---------------------------------

'Create the e-mail server object 
Set objCDOMail = Server.CreateObject("CDONTS.NewMail") 

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent) 
objCDOMail.From = "<" & strReturnEmailAddress & ">" 

'Who the e-mail is sent to 
objCDOMail.To = strMyEmailAddress 

'Who the carbon copies are sent to 
objCDOMail.Cc = strCCEmailAddress 

'Who the blind copies are sent to 
objCDOMail.Bcc = strBCCEmailAddress 

'Set the e-mail body format (0=HTML 1=Text) 
objCDOMail.BodyFormat = 0 

'Set the subject of the e-mail 
objCDOMail.Subject = "Test Title" 

'Set the main body of the e-mail 
objCDOMail.Body = strBody 

'Importance of the e-mail (0=Low, 1=Normal, 2=High) 
objCDOMail.Importance = 1 

'Send the e-mail 
objCDOMail.Send 

'Close the server object 
Set objCDOMail = Nothing 

'-------------------------------------------------------AUTO RESPONDER ADDED BY Mhtml------------

'Create the e-mail server object 
Set objCDOMail = Server.CreateObject("CDONTS.NewMail") 

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent) 
objCDOMail.From = "<" & strMyEmailAddress & ">" 

'Who the e-mail is sent to 
objCDOMail.To = strAutoEmailAddress 


'Set the e-mail body format (0=HTML 1=Text) 
objCDOMail.BodyFormat = 0 

'Set the subject of the e-mail 
objCDOMail.Subject = "Auto Response to order submission" 

'Set the main body of the e-mail 
objCDOMail.Body = strAutoBody 

'Importance of the e-mail (0=Low, 1=Normal, 2=High) 
objCDOMail.Importance = 1 

'Send the e-mail 
objCDOMail.Send 

'Close the server object 
Set objCDOMail = Nothing 



%> 
<html> 
<head> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<title>Test</title> 

</head> 


<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099" alink="#FF0000"> 
<br> 

</body> 


</html>
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 07-30-2002, 12:00 AM   PM User | #15
dhtmlhelp
Regular Coder

 
Join Date: Jun 2002
Location: London, UK
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
dhtmlhelp is an unknown quantity at this point
Fantastic

It's working great now, thanks MHTML.

One last thing, how can I personalise the Autoresponse. For example if joe@domain.com submits his email how can I get the automated reply to read:

Hi Joe,

etc.

DHTMLHELP
dhtmlhelp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:57 PM.


Advertisement
Log in to turn off these ads.