Email from form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colinod
    Contributor
    • Nov 2007
    • 347

    Email from form

    HI

    I was wondering if it is possible to send text from a form to a web page via a cdo email.

    I.e> can i have someone type in a message in a form and then have the form directed to a cdo email asp page and have that generate the email from a webpage that will contain the typed text.

    I have it all working but just wanted to know if i could add a personal message to a page as it is for marketing perposes

    thanks for any help
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    The easiest way to send data would be in querystring, but that is of course somewhat limited. But if you just want to have a personalized response that would be easiest. In fact a lot of marketers encode the image links with querystring data (<img src="www.mydoma in.com/images/imagetracker.cg i?imgID=2345&em ailID=your_name-domain.com">) so that when the message is opened they know. That's why my email client (and I would assume a lot of other clients) blocks images by default if they aren't attached to the message.

    Most email clients will accept HTML pages as email messages, whether they will interpret the form correctly may depend on the client. Definitely test to make sure, but I would bet most would interpret it just fine.

    Jared

    Comment

    • colinod
      Contributor
      • Nov 2007
      • 347

      #3
      yes i thought that a querystring would be the way to go, what i cant figure out is the code in the cdo email page that will code the link and send the querystring

      i have a form with a field called body2 that will hold the text i wanted to add and an email asp page that generates the email from a hidden field in the form called link, as follows

      hidden field in form
      Code:
      <input name="link" type="hidden" value="http://www.yaketyyak.co.uk/mailout/viewshortlist3.asp?cart=<%= server.urlEncode( session("recordsInCart")) %>">
      body 2 field in form
      Code:
      <TEXTAREA name="body2" id="body2" cols="40" rows="5"></TEXTAREA>
      in the email asp page the line that generates the email from web page is as follows
      Code:
      usrmail.CreateMHTMLBody Request.Form("link")
      this all works fine but i cant add the querystring, i have tried
      Code:
      usrmail.CreateMHTMLBody Request.Form("link") & "?text=" & Request.Querystring("body2")
      But that does not seem to work

      Comment

      • colinod
        Contributor
        • Nov 2007
        • 347

        #4
        hi

        i hope someone can help with this.

        I have managed to get the url to get itself together in the following code, what i cant do is get the cdo CreateMHTMLBody to generate the email using the generated url which i have stored in a variable

        Code:
        <%
        
        'Sends an email
        URL = Request.Form("link") & "&text=" & Request.Form("body2")
        response.write URL
        Dim usrmail
        Set usrmail=Server.CreateObject("CDO.Message")
        usrmail.To=Request.Form("To")
        usrmail.From="voiceovers@yaketyyak.co.uk"
        usrmail.Bcc=Request.Form("Bcc1")
        usrmail.Subject=Request.Form("Subject")
        usrmail.CreateMHTMLBody URL
        usrmail.Send()
        Response.Write("")
        'Destroy the mail object!
        Set usrmail = nothing
        %>

        Comment

        • colinod
          Contributor
          • Nov 2007
          • 347

          #5
          have now changed it again and found what is stopping it from working i just dont know how to fix iy

          code is

          Code:
          <%
          
          'Sends an email
          Dim usrmail
          Dim usrcart
          Dim usrtext
          usrcart = Request.Form("link") & "&text=" & Request.Form("body2")
          Response.Write (usrcart)
          Set usrmail=Server.CreateObject("CDO.Message")
          usrmail.To=Request.Form("To")
          usrmail.From="voiceovers@yaketyyak.co.uk"
          usrmail.Bcc=Request.Form("Bcc1")
          usrmail.Subject=Request.Form("Subject")
          usrmail.CreateMHTMLBody "http://www.yaketyyak.co.uk/mailout/viewshortlist3.asp" & usrcart
          usrmail.Send()
          Response.Write("")
          'Destroy the mail object!
          Set usrmail = nothing
          %>
          problem is when the Request.Form("b ody2") variable contains spaces, this is where the personal bit of text i want to be on the web page that makes the email is contained!!!!

          Any help would be appreciated

          Comment

          • jhardman
            Recognized Expert Specialist
            • Jan 2007
            • 3405

            #6
            Try this:
            Code:
            usrcart = Request.Form("link") & "&text=" & _
            server.urlencode(Request.Form("body2"))
            (converts a string to make it compatible with URLs

            Jared

            Comment

            • colinod
              Contributor
              • Nov 2007
              • 347

              #7
              Thanks for that, works ok but does anyone know how to get any line returns entered in the form to appear on the page the text is on, i can do it by typing in HTML <BR> tags but was hoping for something else

              Comment

              • colinod
                Contributor
                • Nov 2007
                • 347

                #8
                sorted it now thanks just used the replace funtion to replace all the encoded characters

                Comment

                Working...