Connecting Tech Pros Worldwide Forums | Help | Site Map

How to auto send an email using asp classic.

Newbie
 
Join Date: Oct 2008
Posts: 15
#1: Oct 11 '09
Hi Everyone,

I'm just a beginner on asp, just want to ask for the help on how I could do to have a auto email send on my program. Just please give me some basic codes like if the user click OK then it will automatic send a email to specific email address with subject "thank you" and body text "please reply"

thank you in advance for the help

RJ

Newbie
 
Join Date: Oct 2008
Posts: 15
#2: Oct 11 '09

re: How to auto send an email using asp classic.


Hi in additon i did this but the problem is i did not received the email. please help. thanks
Expand|Select|Wrap|Line Numbers
  1. Dim myMail
  2.  
  3. Set myMail=CreateObject("CDO.Message")
  4.  
  5. myMail.Subject="Sending email with E2E"
  6. myMail.From="mymail1@ab.com.ph"
  7. myMail.To="mymail@ab.com.ph"
  8. myMail.TextBody="This is a message."
  9. myMail.Send
  10. set myMail=nothing
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#3: Oct 12 '09

re: How to auto send an email using asp classic.


Hello rjlorenzo,

Here is a one page example that you can use/tweak.


Page is called: ThisPage.asp

Expand|Select|Wrap|Line Numbers
  1. <% 
  2.     If (Request.Form("xSendMessage")) Then 
  3.         Set myMail=CreateObject("CDO.Message") 
  4.         myMail.Subject = Request.Form("xSubject") 
  5.         myMail.From = "Billy@billy.com" 'Place an email address here so when someone replies to this email you will get it. 
  6.         myMail.To = Request.Form("xEmail") 
  7.         myMail.TextBody = Request.Form("xMessage") 
  8.  
  9.         On Error Resume Next  
  10.            myMail.Send     
  11.            If Err <> 0 Then  
  12.               Response.Write("<h3><Font Color='#FF0000'>Error occurred: <i>" & Err.Description & "</i></Font></h3>") 
  13.            else 
  14.               Response.Write("Your message was sent successfully.") 
  15.            End If 
  16.     End If 
  17. %> 
  18. <html> 
  19.     <head> 
  20.         <title>Example</title> 
  21.     </head> 
  22.     <body> 
  23.         <form method="post" action="ThisPage.asp" name="xForm" id="xForm"> 
  24.             <input type="hidden" name="xSendMessage" value="true"> 
  25.             Full Name: <input type="text" name="xName" size="50"><br> 
  26.             Email: <input type="text" name="xEmail" size="50"><br> 
  27.             Subject: <input type="text" name="xSubject" size="50"><br> 
  28.             Message: <textarea name="xMessage" cols="50" rows="5"></textarea><br> 
  29.             <input type="submit" value="submit"> 
  30.         </form> 
  31.     </body> 
  32. </html> 
  33.  
If you get an error this should tell you why.


Hope this helps,
CroCrew~
Newbie
 
Join Date: Oct 2008
Posts: 15
#4: Oct 15 '09

re: How to auto send an email using asp classic.


Hi thanks you for reply, still didn't recieved the mail and no error message or successful message display. see my complete code below.
Expand|Select|Wrap|Line Numbers
  1. if grp <> act_stage then
  2.  
  3. Dim myMail
  4. Set myMail=CreateObject("CDO.Message")  
  5.         myMail.Subject = "testing auto email"  
  6.         myMail.From = "ab@xxx.com.ph"   
  7.         myMail.To = "cd@xxx.com.ph"  
  8.         myMail.TextBody = " e2e TMS auto email testing if stage to other group"
  9.  
  10.         On Error Resume Next   
  11.            myMail.Send      
  12.            If Err <> 0 Then   
  13.               Response.Write("<h3><Font Color='#FF0000'>Error occurred: <i>" & Err.Description & "</i></Font></h3>")  
  14.            else  
  15.               Response.Write("Your message was sent successfully.")  
  16.            End If  
  17.  
  18. set myMail=nothing
  19. end if
  20.  
  21. response.redirect ("prs_editrec.asp?user="&user&"&recnum="&recnum)
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#5: Oct 15 '09

re: How to auto send an email using asp classic.


It could be that your ISP is blocking the email. Also, check your spam folder.

CroCrew~
Newbie
 
Join Date: Oct 2009
Location: Grant, AL
Posts: 17
#6: Oct 20 '09

re: How to auto send an email using asp classic.


Try changing line 4 to:

Expand|Select|Wrap|Line Numbers
  1. Set myMail = CreateObject("CDONTS.Newmail")
  2.  
Reply