Sending email and email attachments from DPS publications

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

11 Responses to Sending email and email attachments from DPS publications

  1. It looks like your drop-down solution is no longer working. I just tried it out and couldn’t get it to work, then I downloaded your app and your example is not working either.

    • James Lockman says:

      Re-download the Folio Producer tools and install them again. This is a known issue that we have fixed.

  2. I don’t think it has anything to do with Folio Producer. I am looking at your folio on the iPad, not one that I made. I’ve noticed that on an iPad 1, your drop-down menu works. But on the iPad 3 it does not.

  3. Okay I see you have fixed it. I just updated the article and the drop-down now works. How did you fix it? Is there something in the code that has changed? You say to re-download Folio Producer tools, I am trying to figure out how to re-download them right now.

    • James Lockman says:

      Hi, David.

      Fixing the issue involved reinstalling the DPS tooling, which I did from the DPS Console. Since then, though, you should have gotten a notice from the Adobe Updater that new DPS software was available.

  4. Susanne says:

    Dear James, thank you for the tutorial which was very helpful. Do you know why the JavaScript Code: this.mailDoc({Subject: “subject line”}); is not working on an iPAD? We were trying to integrate the email attachment directly via the Javascript functions in Acrobat but the button won’t even be displayed on the iPAD. Do you know why? Thank you in advance. With best wishes, Susanne

    • James Lockman says:

      Sorry, Suzanne, I don’t know, although I’d assume that it stems from the differences between the webkit overlay and Safari.

  5. Pingback: Launching external apps from a DPS folio

  6. QUESTION IN BRIEF
    Is it possible to use custom url strings and a very small XCode app to store the value of a variable in the app, or the folio, or in an associated file… so that the value of the variable can be retrieved when the user clicks a button or link?

    BACKGROUND BEHIND THE QUESTION
    We’re working on a multi-folio app which will be focused on advertising real-estate rentals. Our marketing plan calls for signing up property agents from many rental companies to be “sales affiliates” and to send out newsletters to their email lists, encouraging their clients to download our free app.

    Within the app, each property listing would have a Book Now button. When a user clicks on a Book Now button for a particular property, an html form overlay would appear allowing the user to enter basic information such as name, email addr, phone number and rental timeframe and duration. A hidden field would contain the unique identifier for that particular property. Once the form is submitted, an agent would follow up with emails and/or phone calls to confirm availability and to complete each booking.

    But, that brings up a wrinkle in our plans, because we’re wanting to create only one version of the app and of each folio/issue.

    We’d like to somehow be able to create dynamic links for the forms which would include an affiliate code. Or to assign a hidden form field to be the value of the affiliate code. If we could do either of those things, then we would program the action for all forms to be sent to our own website for processing by PHP which would allow us to parse out the affiliate code… and readdress/redirect the form data to the appropriate rental agency. That way, that agency is assured of being able to collect the commission after they complete the booking.

    We’re wondering if it’s possible that during the app install the user could select the agency that emailed them from a drop-down list, and the associated affiliate code could somehow get stored in our app? Or in some external file or even a very basic XCode app? If this would work with an associated XCode app, then we could provide unique versions of that app for each of our affiliate agents that could be included as an attachment that would be sent with the newsletter providing the download link for our app.

    Or could we ask new users upon the completion of the installation of the app to set up an account, which would include selecting the proper agent that informed them about the free app. (Which might allow a Javascript query upon loading the booking inquiry form to retrieve the affiliate code….)

    Sorry for all the blah, blah, blah… but maybe the explanation helps.

    • James Lockman says:

      Hi, Rick.

      This question comes up frequently from our customers, and there are several approaches to identifying a rep in a sales situation. You are right on the money, so to speak, with your two approaches: the first being the customer selects a rep and the second being that the customer logs in to the app. Before we proceed, it is important to know whether you are using a Pro or an Enterprise DPS account. If you are using Pro, then you need to likely use the former method, and if you are using Enterprise, then you can use either method.

      Menu in a form method
      This method is the easiest to conceptualize, and you outlined it very well. I will expand on that method a little bit to make it a little less annoying for your customer. Assuming that you have a “book now” button in a Web Overlay (this will be the only efficient way to do this…) in your article, you might want to hide that behind your “choose your rep” menu. Have an onchange event handler that:

      Stores the value in localStorage["repCode"]
      Exposes the “Book Now” button and puts the value of the menu pick into a hidden field
      Passes the value off to the PHP form in the hidden field when the user taps the Book Now button.

      In addition, you need to wrap the menu in a test that hides the menu and exposes the “Book Now” button if the localStorage["repCode"] item is set. The localStorage["repCode"] item will persist across articles in the folio. You will need to repeat this code over and over throughout the book, with a “Book Now” button on each listing. You may want to get fancy and use my Content Context method and set the article name in the Folio Builder panel to be the listing item number in your database. That way, you can pass the item number (from the article name) and the rep number (from the menu item) to the PHP form.

      Login method
      This method is most effective with an Enterprise Adobe DPS account, because you would likely want to customize the login experience for the new or returning customer. You can put a login form in a Custom Storefront slot that will call an Entitlement Server. The Entitlement Server should allow a user to create a new record and also recover a forgotten login. In the account creation process, you can ask for the person’s address or even their rep’s name, assuming that they have one. The alternative is to have the rep create the account and provide the customer with their personal login credentials, which binds the rep to their customer more tightly.

      After the customer logs in, pass the rep code back to the Storefront and store it in localStorage["repCode"]. In addition, since you are using an Entitlement Server, you could also limit the brochures/folios that the customer sees based on what their rep has listed or based on discussions the customer and the rep may have had. Think of this scenario: the rep locates several properties that she wants to share with her customer. She logs in to the Entitlement Server and selects those properties and “shares” them with her client. The client logs into the DPS app, and the Entitlement server then restricts his view to those properties that his rep shared with him. Nice and neat.

      This scenario would also use the “Book Now” buttons from the earlier scenario, but now the rep code would be supplied during login and not in a folio. From my perspective (and I don’t run your business so I can only speak from the client side of the equation), I’d prefer to have a relationship with my rep and let my rep do some work to provide me with that hand-picked list of appropriate properties. You could also serve a list in a Google Map in the Custom Storefront with a viewing itinerary and driving directions between the locations.

      Please let me know how you decide to proceed with this, as I am very interested in this use case. Thanks for commenting, Rick.

  7. OH MY GOODNESS JAMES! Thanks so so much for the detailed answer… and I am VERY VERY pleased that it now appears that we can in fact do what we were hoping to do – provide one version of the app and one version of each issue/folio.

    We have not actually made the determination of whether to go with the Pro or the Enterprise account. But I have to say I’m leaning towards the Enterprise version after your suggestion about also presenting a Google Map in a custom storefront which would show locations for the various properties we’ve featured. Plus your comments about providing ways to “tighten” the relationship between the travel agency rep and their clients is also added value to the travel agency, and it something that makes a LOT of sense!

    Thanks again so much and I will be very happy to keep you posted on our progress. (By the way, these will all be very high-end luxury villas in Bali Indonesia. Feel free to check out some of the villa photos on our website if you’d like – www dot luxviz dot com)

    Rick