Join Keith Gilbert for an in-depth discussion in this video Create a button to precompose email, part of InDesign: Fixed-Layout EPUB Interactive Techniques & Publish Online.
- What if you want to include a button that generates a pre-composed email where you provide the text for the body of the email that will be sent? You can do this in InDesign with a little bit of elbow grease and the help of a couple of free scripts. In the Exercise Files folder, in the 07 Generating custom emails folder, you'll see a couple files that end in .jsx. You're going to want to install these scripts in InDesign to make this process much easier. If you need to learn how to install scripts in InDesign, see my How to Install a Script movie in my InDesign Scripting Made Easy course.
Open the 07_02_email_begin file in InDesign and if you scroll beneath the page you'll see that on the pace board I've created a text frame and put a whole bunch of text in it. We're ultimately going to copy and paste all of this text into a tiny text field in the Hyperlinks panel. Rather than try to type all of this text in that field it's much easier to put it all together on the pace board somewhere first and then later copy and paste it into the panel. Note that the first line begins with mailto:? and then subject= blah, blah, blah, and body= blah, blah, blah.
The mailto:? text indicates that the email should not be pre-addressed to anybody. The subject= and body= means to precede the subject and the body text. Then you can enter whatever you want for the subject and body. A plain text email is what's ultimately going to be composed so you can't specify any format in like bold, italic, or font color. But you can include returns, spaces, em dashes, and en dashes but for these and any other special characters to work properly in the email they have to be encoded into valid ASCII characters.
Now what does that mean? If you look st this w3schools.com webpage here and scroll down far enough you'll see a large table that lists out all kinds of characters along with a code to the right of the characters. So here we have a bullet and we see that the code for that is %95, and a en dash, %96, and a em dash, %97, etcetera. Those are the codes that we need to type into our text if we want to use them. Well this is where the scripts come in to make life much easier for us because we have to put a code in even for every space character and every return character, which is really tedious.
So what we can do instead is select all of the text, go to the Window, Utilities, Scripts panel, and just double click on URL encode for EPUB script. Double clicking on that replaces all the spaces with %20s and, for example, if we look right here there was a em dash I believe, right before my name, so that shows up as a %94, all the returns are also replaced with code so it takes care of all that for you.
After you've done that, for some reason, you need to go back to the un-encoded text, you just select all the text again and run the URL decode script and that puts it back the way it was. And then you can edit the text or whatever and then when you're finished select it again and run the URL encode script. So once you've done that you want to select all this text, copy it with commander control c, and then just create a clear frame where you want the tappable region to be and go to your Hyperlinks panel, create a new hyperlink, make sure it's a URL hyperlink, and select the text that's in the URL field, delete it, and do a paste, commander control v.
And that takes that whole paragraph of text, and pastes it in that tiny little field, and then you can just OK out of this. Let's preview that and see if it works. So in the EPUB interactivity preview panel click the Play button, click on the email, and it should generate an email that is not pre-addressed to anybody but the subject and the body are pre-filled for you. By the way, in InDesign you can also create buttons that have a go to URL action.
But if you use that method the result won't work in a fixed layout EPUB even though it previews properly in the EPUB interactivity preview panel. So be careful, you have to use the hyperlinked panel for this to work correctly. Also, at the time of this recording, this technique won't work in Publish Online output. You can even include a link to other content such as PDF images or videos within the body of your email. The easiest way to do this would be to place the asset in cloud storage such as Dropbox, Google Drive, or OneNote, generate a link to the asset, and then paste the link in the body of your email.
To learn how to generate a link to a file that's saved in Dropbox, see the Share Files and Folders with Anyone movie in my Up and Running with Dropbox course. This technique, though a bit fussy, allows you to create buttons that generate emails that contain all types of content for your users.
- Creating animated navigation buttons
- Building interactive slideshows
- Creating reveal buttons
- Adding multiple choice and branching quizzes
- Creating a scrolling panorama
- Embedding video
- Creating buttons to send email