Guest User

Untitled

a guest
Feb 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. <head>
  2. <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.css">
  3. <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.components.css">
  4. <meta charset="utf-8">
  5. <title>Microsoft Graph Connect sample</title>
  6. <base href="/">
  7.  
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link rel="icon" type="image/x-icon" href="favicon.ico">
  10.  
  11. <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
  12.  
  13. <script>
  14. window.history.replaceState = function(){};
  15. window.history.pushState = function(){};
  16. </script>
  17.  
  18. </head>
  19.  
  20. <body>
  21. <app-root></app-root>
  22. <button onclick="setItemBody()">Paste to email</button>
  23.  
  24. <script type="text/javascript" src="node_modules/core-js/client/core.js"></script>
  25. <script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
  26. <script type="text/javascript" src="node_modules/office-ui-fabric-js/dist/js/fabric.js"></script>
  27.  
  28. <script type="text/javascript" src="app.js"></script>
  29.  
  30. </body>
  31.  
  32. </html>
  33.  
  34. var item;
  35.  
  36. Office.initialize = function () {
  37. item = Office.context.mailbox.item;
  38. // Checks for the DOM to load using the jQuery ready function.
  39. $(document).ready(function () {
  40. // After the DOM is loaded, app-specific code can run.
  41. // Set data in the body of the composed item.
  42. // setItemBody();
  43. });
  44. }
  45.  
  46. // Get the body type of the composed item, and set data in
  47. // in the appropriate data type in the item body.
  48. function setItemBody() {
  49. item.body.getTypeAsync(
  50. function (result) {
  51. if (result.status == Office.AsyncResultStatus.Failed){
  52. write(result.error.message);
  53. }
  54. else {
  55. // Successfully got the type of item body.
  56. // Set data of the appropriate type in body.
  57. if (result.value == Office.MailboxEnums.BodyType.Html) {
  58. // Body is of HTML type.
  59. // Specify HTML in the coercionType parameter
  60. // of setSelectedDataAsync.
  61. item.body.setSelectedDataAsync(
  62. '<b>These are the times I am available:</b><br>Monday -- 8:30 to 9:00<br>Tuesday -- 1:00 to 5:00<br>Thursday -- 4:00 to 5:00<br>',
  63. { coercionType: Office.CoercionType.Html,
  64. asyncContext: { var3: 1, var4: 2 } },
  65. function (asyncResult) {
  66. if (asyncResult.status ==
  67. Office.AsyncResultStatus.Failed){
  68. write(asyncResult.error.message);
  69. }
  70. else {
  71. // Successfully set data in item body.
  72. // Do whatever appropriate for your scenario,
  73. // using the arguments var3 and var4 as applicable.
  74. }
  75. });
  76. }
  77. else {
  78. // Body is of text type.
  79. item.body.setSelectedDataAsync(
  80. ' Kindly note we now open 7 days a week.',
  81. { coercionType: Office.CoercionType.Text,
  82. asyncContext: { var3: 1, var4: 2 } },
  83. function (asyncResult) {
  84. if (asyncResult.status ==
  85. Office.AsyncResultStatus.Failed){
  86. write(asyncResult.error.message);
  87. }
  88. else {
  89. // Successfully set data in item body.
  90. // Do whatever appropriate for your scenario,
  91. // using the arguments var3 and var4 as applicable.
  92. }
  93. });
  94. }
  95. }
  96. });
  97.  
  98. }
  99.  
  100. // Writes to a div with id='message' on the page.
  101. function write(message){
  102. document.getElementById('message').innerText += message;
  103. }
Add Comment
Please, Sign In to add comment