How to auto send an email using asp classic.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rjlorenzo
    New Member
    • Oct 2008
    • 16

    How to auto send an email using asp classic.

    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
  • rjlorenzo
    New Member
    • Oct 2008
    • 16

    #2
    Hi in additon i did this but the problem is i did not received the email. please help. thanks
    Code:
    Dim myMail
    
    Set myMail=CreateObject("CDO.Message")
    
    myMail.Subject="Sending email with E2E"
    myMail.From="mymail1@ab.com.ph"
    myMail.To="mymail@ab.com.ph"
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing
    Last edited by Frinavale; Oct 15 '09, 03:13 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Hello rjlorenzo,

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


      Page is called: ThisPage.asp

      Code:
      <% 
          If (Request.Form("xSendMessage")) Then 
              Set myMail=CreateObject("CDO.Message") 
              myMail.Subject = Request.Form("xSubject") 
              myMail.From = "Billy@billy.com" 'Place an email address here so when someone replies to this email you will get it. 
              myMail.To = Request.Form("xEmail") 
              myMail.TextBody = Request.Form("xMessage") 
        
              On Error Resume Next  
                 myMail.Send     
                 If Err <> 0 Then  
                    Response.Write("<h3><Font Color='#FF0000'>Error occurred: <i>" & Err.Description & "</i></Font></h3>") 
                 else 
                    Response.Write("Your message was sent successfully.") 
                 End If 
          End If 
      %> 
      <html> 
          <head> 
              <title>Example</title> 
          </head> 
          <body> 
              <form method="post" action="ThisPage.asp" name="xForm" id="xForm"> 
                  <input type="hidden" name="xSendMessage" value="true"> 
                  Full Name: <input type="text" name="xName" size="50"><br> 
                  Email: <input type="text" name="xEmail" size="50"><br> 
                  Subject: <input type="text" name="xSubject" size="50"><br> 
                  Message: <textarea name="xMessage" cols="50" rows="5"></textarea><br> 
                  <input type="submit" value="submit"> 
              </form> 
          </body> 
      </html>
      If you get an error this should tell you why.


      Hope this helps,
      CroCrew~

      Comment

      • rjlorenzo
        New Member
        • Oct 2008
        • 16

        #4
        Hi thanks you for reply, still didn't recieved the mail and no error message or successful message display. see my complete code below.
        Code:
        if grp <> act_stage then
        
        Dim myMail
        Set myMail=CreateObject("CDO.Message")  
                myMail.Subject = "testing auto email"  
                myMail.From = "ab@xxx.com.ph"   
                myMail.To = "cd@xxx.com.ph"  
                myMail.TextBody = " e2e TMS auto email testing if stage to other group"
          
                On Error Resume Next   
                   myMail.Send      
                   If Err <> 0 Then   
                      Response.Write("<h3><Font Color='#FF0000'>Error occurred: <i>" & Err.Description & "</i></Font></h3>")  
                   else  
                      Response.Write("Your message was sent successfully.")  
                   End If  
        
        set myMail=nothing
        end if
        
        response.redirect ("prs_editrec.asp?user="&user&"&recnum="&recnum)
        Last edited by Frinavale; Oct 15 '09, 03:13 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

        Comment

        • CroCrew
          Recognized Expert Contributor
          • Jan 2008
          • 564

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

          CroCrew~

          Comment

          • gcube
            New Member
            • Oct 2009
            • 16

            #6
            Try changing line 4 to:

            Code:
            Set myMail = CreateObject("CDONTS.Newmail")

            Comment

            Working...