8 Replies Latest reply on Apr 25, 2014 11:47 AM by essejesse

    alert to display two pieces of information simultaneously

    essejesse Level 1

      I need an alert to display a message and also a placed item name

       

      the placed item name is placedItems[0].file.name and I want the alert to say, "Make note of the file with an error, this file will not be saved." and then display that name. Is this possible?

       

      I thought I could just do two alerts, but that's ridiculous to deal with if you are using the script for a lot of files.

       

      Ideally, the script would generate an email with the body containing the names of any files that had errors noted by the user, but I don't think I'm going to understand how to do things like that just yet. Can you even generate an email from an Illustrator script?

        • 1. Re: alert to display two pieces of information simultaneously
          pixxxel schubser Level 5

          essejesse wrote:

           

          I need an alert to display a message and also a placed item name

           

          the placed item name is placedItems[0].file.name and I want the alert to say, "Make note of the file with an error, this file will not be saved." and then display that name. Is this possible? …

           

          Do you mean something like this?

           

          //alert("Make note of the file with an error, this file: "+placedItems[0].file.name+" will not be saved.");
          alert("Make note of the file with an error, this file: "+app.activeDocument.name+" will not be saved.");
          

           

          An email from script? I don't know.

           

          But you can write your messages in a txt.file:

           

          var message1 = "Hallo ";
          var message2 = "mein ";
          var message3 = "Freund";
          
          aFile = File("~/Desktop/test.txt");
          aFile.open('w', "TEXT", "R*ch");
          aFile.writeln(message1+message2+message3); 
          aFile.close();
          alert("test.txt was created on your Desktop");
          

           

          Have fun

           

          1 person found this helpful
          • 2. Re: alert to display two pieces of information simultaneously
            [Jongware] Most Valuable Participant

            pixxxel schubser wrote:

             

            An email from script? I don't know.

             

            But you can write your messages in a txt.file:

            ...

             

            1. Instead of .txt, use the extension .eml (that is ee em ell) for your new file

            2. Use the following format. "Date", "From", "Subject" and "To" must be followed by a blank line! (Or so I discovered after trying to leave it out.)

             

            Date: Fri, 25 Apr 2014 00:28:25 +0100
            From: yourown@ddress.com
            Subject: Welcome
            To: someoneelses@ddress.com
            
            Hi,
            Please read this:
            .... (more text)
            Sincerely,
            essejesse
            
            

             

            3. Save it at a known location

            4. Issue this as last command:

             

            yourFile.execute();

             

            5. The generated mail will open automatically in your user's Mail client. Instruct them to press "Send"

             

            A fully working script -- NOTE THE REQUIRED BLANK LINE:

             

            message1 = "Oh okay this works";
            
            aFile = File("~/Desktop/test.eml");
            aFile.open('w');
            aFile.writeln("Date: Fri, 25 Apr 2014 00:28:25 +0100");
            aFile.writeln("From: essejesse@essejesseincorporated.com");
            aFile.writeln("Subject: Welcome");
            aFile.writeln("To: your@ddress.com");
            aFile.writeln();          // IMPORTANT! LEAVE THIS LINE BLANK!
            aFile.writeln("Hi,");
            aFile.writeln("Please read this:");
            aFile.writeln(message1);
            aFile.writeln("Sincerely,");
            aFile.writeln("essejesse");
            aFile.close();
            
            aFile.execute();
            
            1 person found this helpful
            • 3. Re: alert to display two pieces of information simultaneously
              pixxxel schubser Level 5

              Hi @[Jongware],

              great stuff and very interesting.

               

              I have not yet needed, but it's always good to know. Thanks for sharing.

               

              • 4. Re: alert to display two pieces of information simultaneously
                essejesse Level 1

                Wow, really cool stuff. Thanks to the both of you.

                 

                So I've got this email code in there now and it generates the email and opens the email client, but a few things aren't working how I want and I wonder if there's a way to change it.

                 

                First, it's not able to be sent, it acts as though it's an email that has already been sent. I can forward, or reply. This is the big one.

                 

                Second, the date, do I have to put that in there? Or is there a way for it to dynamically put the current date/time in? Got this one

                 

                Third, earlier in the script, I have the placedItems[0].file.name set as a variable, as the script is running through a list of files and repeatedly placing an item, and using it's name. I'm wondering if there's a way for the email to be generated with all the files that are marked as incorrect in the body of the email. It's this script. Just skip to the answer I marked correct.

                 

                On that third one, I'm actually not all that concerned with this. If the people who send us these files get a single email for every time they make a mistake, maybe it will motivate them to make less mistakes. So I really only need it to have a send button. I don't know if I'm doing something wrong or what.

                 

                Message was edited by: essejesse

                • 5. Re: alert to display two pieces of information simultaneously
                  pixxxel schubser Level 5

                  Hi, essejesse,

                  hmmh? I can't see your problem, sorry. Or I misunderstood? (because of my english isn't the best)

                   

                  Why do you not insert the following at the place in your other script:

                   

                  // …
                  else alert ('Make note of the file with an error. This file will not be saved.');
                  var  message1 = myLinkName + "was marked as incorrect!"; // and your other text
                  // here insert the rest of code for the email (like @[Jongware] wrote)
                  //
                  //
                  app.activeDocument.close (SaveOptions.DONOTSAVECHANGES);
                  // …
                  
                  • 6. Re: alert to display two pieces of information simultaneously
                    [Jongware] Most Valuable Participant

                    essejesse wrote:

                     

                    > .. First, it's not able to be sent, it acts as though it's an email that has already been sent. I can forward, or reply. This is the big one.

                     

                    Apologies -- I had a hunch there was a plain file format to store emails in (.eml) and tested if this opened correctly in Mail. It did, but I did not think to test actually *sending* as well. I'll have to go over the .EML format again and see if that is actually possible.

                    • 7. Re: alert to display two pieces of information simultaneously
                      essejesse Level 1

                      Ahh, ok. In Mail, I can hit send again, which is fine, but I'm trying to include a spot for the user to write what the error was.

                      Also, my colleagues use Outlook for Mac and that doesn't have an option to send again.

                       

                      Let me know if you find anything. I've tried looking up things like this before, but I haven't found anything. I'm also not sure I'd know what to do if I did find something.

                       

                      It's so close to exactly what I need, I can't believe I'm this far.

                       

                      Thanks again!

                      • 8. Re: alert to display two pieces of information simultaneously
                        essejesse Level 1

                        That's exactly what I'm doing, but the email doesn't end up having a send button