Many of my customers have asked how to send an email from within a DPS publication. For instance, in a sales enablement situation, it’s often necessary to share documentation after the salesperson has discussed the products or services with their clients. In an earlier blog post, I detailed how to display PDFs and other document types directly in your DPS applications. While this is good, it’s not a leave-behind that many sales people require. I wanted to explore some ways to send email from DPS publications, and here are a few of the ways I concocted this afternoon. (If you have my DPS Examples app installed on your iPad, and you’re reading this blog on your iPad, then tap here to see examples of sending emails from a DPS folio.)
Just send it!
Often, it is necessary to just send an email to a specific address. This is easiest to achieve with a hyperlink or a button with a URL destination that uses the mailto: tag. For instance,
mailto:someone@example.com?cc=someoneelse@example.com&bcc=andsomeoneelse@example.com&subject=Summer%20Party&body=You%20are%20invited%20to%20a%20big%20summer%20party!
is a URL that will fire off an email in the device email client. This email will be addressed to someone@example.com with CC to someonelse@example.com and BCC to andsomeoneelse@example.com. Its subject will be Summer Party and the content will be You are invited to a big summer party! It will be sent by the default email account on the device’s email client. Copy that URL into a button URL action in InDesign, and presto, you have an email button.
You can get creative with the content, of course. You can include links to files, so long as the link is a fully formed URL path. For iOS Mail, use the <br> tag to go to a new line. For other mail clients, you’ll have to experiment. Here’s how I set up my email button.
The URL destination:
mailto:someone@example.com?subject=Tax%20Time&body=Pay%20your%20taxes!<br>http://www.irs.gov/pub/irs-pdf/fw4.pdf
sends an email to someone@example.com with the subject Tax Time and
Pay your taxes!
http://www.irs.gov/pub/irs-pdf/fw4.pdf
as the message. Most email clients will interpret the link to the PDF as a hyperlink and will allow the reader to click or tap on the link and view the tax form.
Let’s get a little more sophisticated with this now. In InDesign CS6, we can insert HTML directly onto our layouts via the Object>Insert HTML menu. I have created a little form that has two inputs: email address and a menu to choose which file to include as a link in the body of the email message.
Copy and paste the following into your InDesign layout using Object>Insert HTML and preview on your iPad. If you have InDesign CS5 or CS5.5, you can save this as a .html file and point at it in a Web Content overlay.
<style type="text/css">
.emailform {
height: 100px;
width: 350px;
font-family: Verdana, Geneva, sans-serif;
font-size: 16px;
font-style: normal;
text-align: center;
white-space: normal;
}
</style>
<script>
function sendMail() {
var link = "mailto:"+document.getElementById('emailAddress').value
+ "?cc=myCCaddress@example.com"
+ "&subject=" + escape("Pay your Taxes!")
+ "&body=" + escape('Use this form to start the onboarding process.<br><a href="'+document.getElementById('chooseFile').value+'">Download your W-4 form now</a>')
;
window.location.href = link;
}
</script>
</head>
<body>
<div class="emailform">
Email address:
<input type="text" name="emailAddress" id="emailAddress" />
</br>
<select name="chooseFile" id="chooseFile">
<option value="http://www.irs.gov/pub/irs-pdf/fw4.pdf">Federal W4</option>
<option value="http://www.maine.gov/revenue/forms/with/2012/12_w4me.pdf">MAINE W4</option>
</select>
<button onclick="sendMail(); return false">Send email</button>
</div>
</body>
Of course, you will need to modify it to meet your use case, especially whether you want to include the CC line and which files you want in the menu.
Set the InDesign CS6 will automatically create a Web Content Overlay for you, and you need to configure it to your taste. Since I set my background color in CSS to match the background frame color in InDesign, I have set mine to transparent and to autostart with a slight delay so that it will only fire when the user actually views it. You must enable user interactions if you want the user to be able to fill out the form. Note that with iOS Mail, you can use HTML formatting in your message, so have fun with the message body. I believe that this technique only allows about 2000 characters in the body, so you might need to keep your messages short. Also, this javascript method will force the user to agree to be sent to the Mail application from the folio, while the direct URL method won’t. Nevertheless, this is a very flexible and robust solution for creating email forms within your DPS application.
Here’s what my example looks like on the iPad.
Now I tap the Send Email button…
Now I return to my folio and enter some info in the email form…
Pretty neat, eh?
Links to files are OK, but what about attachments?
If you need to send attachments to your email, then you are out of luck with a URL. You will need to implement another method. I’ll describe two of them here.
The easiest to make is a web form with an emailer server-side application as its action. Remember that you can insert HTML forms directly into InDesign CS6 with Object>Insert HTML or by putting the form in an iframe and copying and pasting the iframe code into InDesign CS6. Like my example in the previous section, include a few text fields for To: and From:, and perhaps even a menu to choose which file to attach. You can get fancy and have check boxes or menus that attach multiple files to the email, too. Then, in your emailer server-side application, compose and send an email using the information in the form. I have done this with PHP and MySQL hundreds of times over the years, and it is a rock solid method for sending email attachments. Of course, you should obfuscate that URL or put it behind some kind of login, ideally attached to your company’s LDAP or Active Directory, if you need security.
While I usually turn to PHP and MySQL, there are myriad ways to implement this on your server. Check to see what server-side capabilities are available to you and give it a whirl.
Thinking outside the (Mail)box…
So, what happens if you are offline? The online form won’t work, and you’ll need a different solution. On iOS, you can write a custom app with XCode that can leverage Custom URL schemes to transmit information between apps. The mailto: tag above is an example of one that’s built into iOS. Also included are sms:, tel:, and http:. You can build an app that can respond to a custom URL scheme and deploy that app to all of the users who need to send emails. Here’s an example of XCode projects that, when built, communicate with each other. http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-working-with-url-schemes/
Let’s say the app named Enterprise Email that has an ID of com.adobe.jameslockman.emailsenderapp has the registered the custom URL scheme sendemail: in its plist. I can then construct a URL using either of my methods shown above in DPS that will tell iOS to communicate with Enterprise Email using URL encoding, such as: sendemail://someone@example.com&from=me@mycompany.com&file=filename.pdf This URL is easy to populate as the result of a form with or without javascript in a web content overlay.
It’s up to you to determine how to parse the incoming string in your custom app. In addition, you should probably have the app check in to a central file repository from time to time and pick up the list of available files and store them internally. The app should also have the ability to cache email sending requests so that it can wait until it gets a network connection to send its emails. This method completely bypasses Mail and will require the app to enable its own email sending methods. I do not have an example of this in action, but I’m considering building out a simple XCode example. If I do, I’ll post it as another entry and link to it here.
This method will only be applicable to an Enterprise who can manage deployment of apps to its installed base of devices through a Mobile Device Management (MDM) solution or other deployment method such as manual sideloading.
It’s in the mailbag
Remember that your ability to actually send email is dependent on your reader actually completing the email task in Mail. Also, the email will always be sent from their default account. They can always choose not to send the message, but in a sales situation, the sales rep will definitely want to send the message. Also, this provides an offline protection, since Mail lets you cache emails until there is an active network connection. If you need to send attachments, then you will need to look at an always online solution or the helper app solution. Your use case will dictate how far you need to go down the development road, but start simple with a URL or an embedded form. It just might be the all you need.
Share on Facebook





















