message.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  6. <meta name="HandheldFriendly" content="true"/>
  7. <meta name="MobileOptimized" content="320"/>
  8. <title>Hello H5+</title>
  9. <script type="text/javascript" src="../js/common.js"></script>
  10. <script type="text/javascript">
  11. function addachmentMail(){
  12. outSet("发送带附件邮件:")
  13. var msg = plus.messaging.createMessage(plus.messaging.TYPE_EMAIL);
  14. msg.to = ['service@dcloud.io'];
  15. msg.body = 'This is an example mail';
  16. msg.addAttachment("_www/img/helloh5.jpg");
  17. plus.messaging.sendMessage( msg );
  18. }
  19. function htmlMail(){
  20. outSet("发送HTML邮件:");
  21. if ( plus.os.name == "iOS" ) {
  22. var msg = plus.messaging.createMessage(plus.messaging.TYPE_EMAIL);
  23. msg.to = ["service@dcloud.io"];
  24. msg.body = '<!DOCTYPE HTML><html><head><meta charset="utf-8"/></head><body><h1>Hello</h1>This is an HTML content mail.</body></html>';
  25. msg.bodyType = "html";
  26. plus.messaging.sendMessage( msg );
  27. outLine("支持");
  28. } else {
  29. outLine("此平台不支持发送HTML邮件功能!");
  30. plus.nativeUI.alert("此平台不支持发送HTML邮件功能!");
  31. }
  32. }
  33. function slientSMS(){
  34. outSet("后台发送短信:");
  35. if ( plus.os.name == "Android" ) {
  36. var bts=["发送到10086","发送到10010","发送到10000"];
  37. plus.nativeUI.prompt("短信内容",function(e){
  38. var to=null;
  39. switch(e.index){
  40. case 0:
  41. to=['10086'];
  42. break;
  43. case 1:
  44. to=['10086'];
  45. break;
  46. case 2:
  47. to=['10086'];
  48. break;
  49. default:
  50. return;
  51. break;
  52. }
  53. var msg = plus.messaging.createMessage(plus.messaging.TYPE_SMS);
  54. msg.to=to;
  55. msg.body=e.value;
  56. msg.silent=true;
  57. plus.messaging.sendMessage( msg );
  58. outLine( "\""+e.value+"\""+bts[e.index] );
  59. },"发送短信","CXYE",bts);
  60. } else {
  61. outLine("此平台不支持后台发送短信功能!");
  62. plus.nativeUI.alert("此平台不支持后台发送短信功能!");
  63. }
  64. }
  65. </script>
  66. <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
  67. </head>
  68. <body>
  69. <br/>
  70. <div class="button" onclick="addachmentMail()">发送附件邮件</div>
  71. <div class="button" onclick="htmlMail()">发送HTML邮件</div>
  72. <div class="button" onclick="slientSMS()">后台发送短信</div>
  73. <br/>
  74. <ul class="dlist">
  75. <li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="sms:10086">发送短信</a></li>
  76. <li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="tel:10086">拨打电话</a></li>
  77. <li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="mailto:service@dcloud.io">发送邮件</a></li>
  78. </ul>
  79. <div id="outpos"/>
  80. <div id="output">
  81. Messaging管理设备通讯功能,可用于发送短信、彩信、邮件等。
  82. </div>
  83. </body>
  84. </html>