5 Replies Latest reply on Dec 17, 2010 12:05 PM by try67

    Populate a field via mailGetAddrs

    ksumwalt

      Hello,

       

      I have created a local .js file with the following to allow the restricted mailGetAddrs function to work:

       

      // Trust the mailGetAddrs function

      KCI_mailGetAddrs = app.trustedFunction( function (cTo, cCc, cBcc, cCaption, bCc, bBcc)

      {

      app.beginPriv();    // Explicitly raise privilege

      app.mailGetAddrs( cTo, cCc, cBcc, cCaption, bCc, bBcc );

      app.endPriv();

      })

       

      I then created a text field, called "Grantee"  I want to have this field look up an employee in our Outlook Contacts, so I put the following in a Mouse Up JavaScript:

      var attempts = 2;

      while (attempts > 0)

      {

      var recipients = KCI_mailGetAddrs

      ({

      cCaption: "Select Recipient, Please",

      cTo: true,

      bBcc: false

      });

      this.getField("Grantee").value = recipients;

      if (recipients == "" ) {

      if (--attempts == 1)

      app.alert("You did not choose any recipients, try again");

      } else break;

      }

      if (attempts == 0)

      app.alert("Cancelling the selection");

      else {

      this.getField("Grantee").value = recipients;

      }

       

      Apparently recipients is not being defined, as it places "undefined" in the Grantee field.  What I want is the person's name, or at the very least their e-mail address.  The this.getField("Grantee")...  was placed in the middle of the above code to try to figure out what was being returned.

       

      When I test this out a window opens called "Check Names" and has amessage stating "Microsoft Outlook does not recognize "[object Object]". and has a button to "Show More Names..." which takes me to the Address Book listing where I can select an employee.  I do this, but nothing is set in the function.

       

      What am I missing here?

        • 1. Re: Populate a field via mailGetAddrs
          try67 MVP & Adobe Community Professional

          In your trusted function you need to return the value returned by mailGetAddrs.


          • 2. Re: Populate a field via mailGetAddrs
            ksumwalt Level 1

            So I now have the trusted function as:

             

            // Trust the mailGetAddrs function

            KCI_mailGetAddrs = app.trustedFunction( function (cTo, cCc, cBcc, cCaption, bCc, bBcc)

            {

            // Additional code may appear above

            app.beginPriv();    // Explicitly raise privilege

            var funcreturn = app.mailGetAddrs( cTo, cCc, cBcc, cCaption, bCc, bBcc );

            // return app.mailGetAddrs( cTo, cCc, cBcc, cCaption, bCc, bBcc );

            // funcreturn = "Memememe!!";

            app.endPriv();

            // Return the returned information.

            return funcreturn;

            })

            And my script is:

             

             

            var attempts = 2;

            while (attempts > 0)

            {

            var recipients = new KCI_mailGetAddrs

            ({

            cTo: "passed.name@company.com",

            cCc: "",

            cBcc: "",

                                    cCaption: "Select Recipient, Please",

                                    bCc: true,

                                    bBcc: true

            });

            this.getField("Grantee").value = recipients;

                            if (recipients == "" ) {

            if (--attempts == 1)

            app.alert("You did not choose any recipients, try again");

            } else break;

            }

            if (attempts == 0)

            app.alert("Cancelling the selection");

            else {

            this.getField("Grantee").value = recipients;

            }

            So when I click the field, a Check Names window opens with

            Microsoft Outlook does not recognize "[object Object]

             

             

            Select the Address to Use:

             

            then a field with no names, but a button to "Show more Names..."  When I click this, I get the Contacts list with only a To option for recipients.  IF I select one, the "Grantee" field gets this:

            selected.name@company.com,undefined,undefined

             

            (NOTE:  passed.name@company.com and selected.name@company.com are not the actual values used. Real values are used, but removed from this post.)

            I have also tried passing the person's name as listed in the Contacts list.  Neither of these do anything.  Also, I have passed nothing here.  All gives the same result.

             

            The problem seems to be that Outlook is not understanding what is being passed, or I am not passing it correctly.  At least I am getting an address.

             

            Any insight on how what might be causing the Outlook message?  Also, how would I get just the email address in the PDF's script?  I know I con process it out by truncating the string to the first comma, but there must be a better way.  recipients.cTo does not get it, which is what I thought I would use.

            • 3. Re: Populate a field via mailGetAddrs
              try67 MVP & Adobe Community Professional

              When I run this code it opens the Outlook address selection dialog with

              "mailto:passed.name@company.com" already filled in. I can then select

              another recipient (let's say "test@test.com"). When I then press enter, the

              value returned is an array with 3 items. The first one is "test@test.com

              ;mailto:passed.name@company.com" and the last two are empty, just like is

              written in the reference.

              Are you not getting the same result?

              • 4. Re: Populate a field via mailGetAddrs
                ksumwalt Level 1

                I am definitely NOT getting the same results.  It sounds like you are getting exactly what I was hoping for, so I am now wondering if it is in Outlook someplace.

                 

                I created a new PDF (File->New in Acrobat Pro 9) and added 2 fields.  1 called Grantee and the other with that executes the javascript I posted on a Mouse Up event.  I get the same results I get in the original, the message:

                     Microsoft Outlook does not recognize "[object Object]"

                 

                I wondered if it is a version problem.  I have Outlook 2007 and am hooked to an Exchange Server.  I also tested on a computer running Outlook 2010 with Exchange.  Either way I get the same results.  2 machines, Windows XP on one, 7 on the other.  Outlook 2007 on the first, 2010 on the second.  The common factor on my end is Exchange.  Is this consistent with you, save the difference in the results?

                • 5. Re: Populate a field via mailGetAddrs
                  try67 MVP & Adobe Community Professional

                  I don't really use Outlook, but I have Outlook Express 6 on my machine (Win

                  XP as well).