ImportantOn Android CSS is not supported, so best practise is not to style the email body, and only use HTML tags.


With mailto it is also possible to send attachments.


There are 2 options to achieve this.


Option 1: mailto using an email.config file

This requires an email.config file in JSON format as shown in the following example: 

 

{ "type":"ecfg", 
   "version":"1", 
   "email_subject" : "Requested documents", 
   "email_body" : "", 
   "email_body_file" : "email/email_body.html", 
   "email_attachments": [{
     "path": "email/ClinicalStudy.pdf",
     "mime_type": "application/pdf"
   }]

}

"_comment": "Copyright (c) 2018 The Interact Technology Group. THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. All rights reserved.",

 

With the ‘email_body_file’ key a html file can be specified to use for the email body.


NOTE: The path to the ‘email_body_file’ and attachments is relative to the ‘content’ folder of the asset as shown in the following graphic.




The next step is to code the mailto link to refer to the email.config file within the index.html file:

 

<a target="_blank" href="mailto:YourName@YourSite.com?cc=someone@YourSite.com&amp;amp;amp;amp;amp;bcc=someoneElse@YourSite.com&amp;amp;amp;amp;amp;subject=Shipping%20Information%20Request&amp;amp;amp;amp;amp;body=Please%20tell%20me%20if%20my%20order%20has%20shipped!&amp;amp;amp;amp;amp;ni_email_cfg_file=email/email.config">Example link</a>

<!-- Copyright (c) 2018 The Interact Technology Group.
THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All rights reserved. -->

 

Again, the path to the the email.config file is relative to the ‘content’ folder of the asset


Option 2: mailto using base64 encoded JSON

This requires code in JSON format as shown in the following example: 


{ "type":"ecfg", 
  "version":"1", 
  "email_to" : "someone@yoursite.com", 
  "email_cc" : ["john@yoursite.com", "jane@yoursite.com"], 
  "email_bcc" : ["bob@yoursite.com"], 
  "email_subject" : "Requested documents", 
  "email_body" : "<html><body>Text</body></html>", 
  "email_attachments" : [{ 
    "path" : "email/ClinicalStudy.pdf", 
    "mime_type" : "application/pdf" }]
}

"_comment": "Copyright (c) 2018 The Interact Technology Group. THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. All rights reserved.",


Use an online tool that encodes JSON to base64. Search the internet by using the following string "JSON to base64".


Encode all of the JSON code to base64. This will return a long string e.g. ‘ub2xvZ3kiXSwNCg...’ that can be incorporated in the mailto tag.  


<a target="_blank" href="mailto:someone@yoursite.com?cc=john@yoursite.com&amp;amp;amp;amp;bcc=bob@yoursite.com&amp;amp;amp;amp;subject=Requested%20documents&amp;amp;amp;amp;ni_email_cfg_base64json=ub2xvZ3kiXSwNCg">Example link</a>

<!-- Copyright (c) 2018 The Interact Technology Group.
THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All rights reserved. -->