3 Replies Latest reply on Jan 20, 2009 3:35 AM by Newsgroup_User

    Order Confirmation Emails -

    Level 7
      Hi All.
      I have an orderconfirmation page that sends out an email to both the
      customer and myself.
      The page uses an include that sets the details for CDONTS and also the body
      of the email (see code below)
      All works fine, but now i want to send two versions of the confirmation
      email, one to the customer and one to myself. The reason for the need for
      two versions is that my version will have, in addition, a simple table with
      boder to allow me to add notes for processing reasons.

      When i put two includes on the order confirmation page (one for each email)
      only one is executed!! - and it's always the second include.
      I have to admit that im not too familiar with using functions, so i'm not
      even sure if this is possible.

      Please see code below:

      OrderConfirmation.asp
      <!--#include file="functions_email_ourcopy.asp" -->
      <!--#include file="functions_email.asp" -->
      <%
      SendEmail CustomersRS("CustomerEmail")
      %>
      ----------------------------------------------------------
      Functions_email_ourcopy.asp
      <%
      'Start the functions
      function SendEmail(c)
      Set objMail = Server.CreateObject("CDONTS.NewMail")
      objMail.From = "me@work.com"
      objMail.To = c
      objMail.Bcc = ""
      objMail.CC = "" 'Maybe send a CC to your sales office
      objMail.Subject = "Order from Website"
      objMail.Body = Mailbody
      objMail.MailFormat=0
      objMail.BodyFormat=0
      objMail.Send
      Set objMail = Nothing
      end function

      function SiteRoot
      'This function tries to ascertain the site root. If it's wrong, enter your
      own manually
      CurrentPage=Request.ServerVariables("SCRIPT_NAME")
      SiteRoot=" http://" & Request.ServerVariables("SERVER_NAME") &
      left(CurrentPage,instrrev(CurrentPage,"/"))
      end function

      Function Mailbody
      'on error resume next
      Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
      ' Call the remote machine the request
      objXML.open "POST", SiteRoot & "email_ourcopy.asp", False
      objXML.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      objXML.send("OrderID=" & OrderID)
      ' return the response
      Mailbody = objXML.responsetext
      ' clean up
      Set objXML = Nothing
      End Function
      %>
      ----------------------------------------------------------

      Functions_email.asp

      <%
      'Start the functions
      function SendEmail(c)
      Set objMail = Server.CreateObject("CDONTS.NewMail")
      objMail.From = "sales@test4less.co.uk"
      objMail.To = c
      objMail.Bcc = ""
      objMail.CC = "" 'Maybe send a CC to your sales office
      objMail.Subject = "Order from Test4Less Website Customer Copy"
      objMail.Body = Mailbody
      objMail.MailFormat=0
      objMail.BodyFormat=0
      objMail.Send
      Set objMail = Nothing
      end function


      function SiteRoot
      'This function tries to ascertain the site root. If it's wrong, enter your
      own manually
      CurrentPage=Request.ServerVariables("SCRIPT_NAME")
      SiteRoot=" http://" & Request.ServerVariables("SERVER_NAME") &
      left(CurrentPage,instrrev(CurrentPage,"/"))
      end function

      Function Mailbody
      'on error resume next
      Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
      ' Call the remote machine the request
      objXML.open "POST", SiteRoot & "email.asp", False
      objXML.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      objXML.send("OrderID=" & OrderID)
      ' return the response
      Mailbody = objXML.responsetext
      ' clean up
      Set objXML = Nothing
      End Function
      %>



        • 1. Re: Order Confirmation Emails -
          Level 7
          Andy wrote:
          > Hi All.
          > I have an orderconfirmation page that sends out an email to both the
          > customer and myself.
          > The page uses an include that sets the details for CDONTS and also the body
          > of the email (see code below)
          > All works fine, but now i want to send two versions of the confirmation
          > email, one to the customer and one to myself. The reason for the need for
          > two versions is that my version will have, in addition, a simple table with
          > boder to allow me to add notes for processing reasons.
          >
          > When i put two includes on the order confirmation page (one for each email)
          > only one is executed!! - and it's always the second include.
          > I have to admit that im not too familiar with using functions, so i'm not
          > even sure if this is possible.

          You are including the same function twice, then only sending one, the
          second time you include the function it overwrites the first, so when
          you call it, it only sends to the second one.

          The solution? Rename the function in the second one, then call it after
          you call the first one.

          <!--#include file="functions_email_ourcopy.asp" -->
          <!--#include file="functions_email.asp" -->
          <%
          SendEmail CustomersRS("CustomerEmail")
          SendEmail2 CustomersRS("CustomerEmail")
          %>

          You might end up with the same content in both, as you have another
          function called Mailbody that is defined twice, so you may need to
          rename that, and where it is called as well.

          Dooza
          • 2. Re: Order Confirmation Emails -
            bregent Most Valuable Participant
            Also, since you are rewriting these functions, now is probably a good time to switch over from CDONTS to CDOSYS.
            • 3. Re: Order Confirmation Emails -
              Level 7
              Hey - Thanks Dooza

              I will be working on this tomorrow and report back - much appreciated

              Regards
              Andy


              "Dooza" <doozadooza@gmail.com> wrote in message
              news:gkpufc$d2e$1@forums.macromedia.com...
              > Andy wrote:
              >> Hi All.
              >> I have an orderconfirmation page that sends out an email to both the
              >> customer and myself.
              >> The page uses an include that sets the details for CDONTS and also the
              >> body of the email (see code below)
              >> All works fine, but now i want to send two versions of the confirmation
              >> email, one to the customer and one to myself. The reason for the need for
              >> two versions is that my version will have, in addition, a simple table
              >> with boder to allow me to add notes for processing reasons.
              >>
              >> When i put two includes on the order confirmation page (one for each
              >> email) only one is executed!! - and it's always the second include.
              >> I have to admit that im not too familiar with using functions, so i'm not
              >> even sure if this is possible.
              >
              > You are including the same function twice, then only sending one, the
              > second time you include the function it overwrites the first, so when you
              > call it, it only sends to the second one.
              >
              > The solution? Rename the function in the second one, then call it after
              > you call the first one.
              >
              > <!--#include file="functions_email_ourcopy.asp" -->
              > <!--#include file="functions_email.asp" -->
              > <%
              > SendEmail CustomersRS("CustomerEmail")
              > SendEmail2 CustomersRS("CustomerEmail")
              > %>
              >
              > You might end up with the same content in both, as you have another
              > function called Mailbody that is defined twice, so you may need to rename
              > that, and where it is called as well.
              >
              > Dooza