6 Replies Latest reply on May 6, 2009 4:07 PM by Chunick

    Email query

    ginod Level 1

      Hi everyone....

      I need to create a window in my proyects, so the users, can send me an email using the app.

       

      Something like other contact me window...

      If any in here, knows, where i can get a source code..

       

      Regards.

      Ginod

        • 1. Re: Email query
          Chunick Level 3

          What you need is code to send email, not how to create a window (or MIAW, as they're called in Director). The Director help should have all the info you need to learn how to open new windows.

           

          Here's the code to send email - even with attachments:

          http://staff.dasdeck.de/valentin/lingo/email_classes/

           

          The code you're looking for is in the 'send Email button' script (member 4) in the on mouseUp handler. It's actually pretty straightforward...

          -- instantiate the SMTP script (member 1)

          -- and pass some needed parameters

          smtp = script("SMTP").new( pSMTPServer, pPort, pUsername, pPassword )

          -- send a property listas a parameter to the sendMail method of the smtp script instance

          pProps = [:]

          pProps["to"] = "to@email.com"
          pProps["from"] = 'from@email.com
          pProps["subject"] = "Email Subject"
          pProps["message"] = "Your email message here"
           
          pProps["cc"] = "cc@email.com"
          pProps["bcc"] = "bcc@email.com"
          pProps["headers"] = ignore this one for now
          pProps["attachments"] = ignore this one for now
           
          pProps["callback"] = #sendMailFeedback
          pProps["callback_target"] = me -- the current script that the smtp instance was created in, ie. a reference to itself


          smtp.sendMail(pProps) -- pFrom, pTo, pSubject, pMsg, headers, pAttachments, pCallbackHandler)

          -- kill the script instance
          smtp = 0

           

          -- you can also set up a callback handler, as the code mentions:

          on sendMailFeedback me, status
            if status=1 then
              alert("Email sent successfully")
            else
              alert("Error sending Email")
            end if
          end

           

          *Note: you didn't specify attachments, so I'm going to leave that up to you to figure out if you're interested, but be aware that you definitely need the base64, File_FileIO and UTILITIES moviescripts to work with Valentin's class to attach files to your emails.

          • 2. Re: Email query
            Sean_Wilson Adobe Community Professional

            You didn't supply enough information. Do you need to add attachments, for example? Which version of Director are you using ?

             

            There are a number of xtras that enable emailing - refer to the Mile High Table O'Products - but my recommendation is that you collect whatever information you require into a property list and use postNetText() to send it to a server-side script that you create on your own server that takes care of emailing. That way if you need to preprocess any of the data sent, or you change your email address, all that's required is to change your server-sdie script instead of updating all the projectors distributed

            • 3. Re: Email query
              Sean_Wilson Adobe Community Professional
              smtp = script("SMTP").new( pSMTPServer, pPort, pUsername, pPassword )

              Kudos to Valentin for what he provides, but the above begs the question: "how likely is it the average user knows his/her server address, port, username and password every time they send an email?"

              • 4. Re: Email query
                Chunick Level 3

                Sean_Wilson wrote:

                 

                smtp = script("SMTP").new( pSMTPServer, pPort, pUsername, pPassword )

                Kudos to Valentin for what he provides, but the above begs the question: "how likely is it the average user knows his/her server address, port, username and password every time they send an email?"

                Sean, you misunderstand. That's the server, port, user and pass info that the developer needs to enter just the one time during development. It's exactly the same as using CDOSYS in ASP for sending user entered form data as an email say in a booking form or 'I would like more information' type form or account activation when signing up to a forum.

                • 5. Re: Email query
                  Sean_Wilson Adobe Community Professional

                  Sean, you misunderstand. That's the server, port, user and pass info that the developer needs to enter just the one time during development.

                  You might be right, but I'm not prepared to concede yet! Doesn't that depend on whose server you're piggy backing off? I agree that if the developer is going to use their own address then it might work if hard-coded - is that what you're suggesting? And if so, doesn't that mean that you have no way of "validating" a return address when an email is sent by an end user?

                  • 6. Re: Email query
                    Chunick Level 3

                    That's about right... in fact, it's the same deal for web based mailers... there are ways to test if the user's email is valid using regex or even by trying to hit the DNS Server for the MX record - but neither are 100% foolproof... and here's a twist with CDOSYS on a windows server... you don't even have to use a legit email account if you use the pickup folder.