Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.css">
- <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/1.0/fabric.components.css">
- <meta charset="utf-8">
- <title>Microsoft Graph Connect sample</title>
- <base href="/">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="icon" type="image/x-icon" href="favicon.ico">
- <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
- <script>
- window.history.replaceState = function(){};
- window.history.pushState = function(){};
- </script>
- </head>
- <body>
- <app-root></app-root>
- <button onclick="setItemBody()">Paste to email</button>
- <script type="text/javascript" src="node_modules/core-js/client/core.js"></script>
- <script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
- <script type="text/javascript" src="node_modules/office-ui-fabric-js/dist/js/fabric.js"></script>
- <script type="text/javascript" src="app.js"></script>
- </body>
- </html>
- var item;
- Office.initialize = function () {
- item = Office.context.mailbox.item;
- // Checks for the DOM to load using the jQuery ready function.
- $(document).ready(function () {
- // After the DOM is loaded, app-specific code can run.
- // Set data in the body of the composed item.
- // setItemBody();
- });
- }
- // Get the body type of the composed item, and set data in
- // in the appropriate data type in the item body.
- function setItemBody() {
- item.body.getTypeAsync(
- function (result) {
- if (result.status == Office.AsyncResultStatus.Failed){
- write(result.error.message);
- }
- else {
- // Successfully got the type of item body.
- // Set data of the appropriate type in body.
- if (result.value == Office.MailboxEnums.BodyType.Html) {
- // Body is of HTML type.
- // Specify HTML in the coercionType parameter
- // of setSelectedDataAsync.
- item.body.setSelectedDataAsync(
- '<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>',
- { coercionType: Office.CoercionType.Html,
- asyncContext: { var3: 1, var4: 2 } },
- function (asyncResult) {
- if (asyncResult.status ==
- Office.AsyncResultStatus.Failed){
- write(asyncResult.error.message);
- }
- else {
- // Successfully set data in item body.
- // Do whatever appropriate for your scenario,
- // using the arguments var3 and var4 as applicable.
- }
- });
- }
- else {
- // Body is of text type.
- item.body.setSelectedDataAsync(
- ' Kindly note we now open 7 days a week.',
- { coercionType: Office.CoercionType.Text,
- asyncContext: { var3: 1, var4: 2 } },
- function (asyncResult) {
- if (asyncResult.status ==
- Office.AsyncResultStatus.Failed){
- write(asyncResult.error.message);
- }
- else {
- // Successfully set data in item body.
- // Do whatever appropriate for your scenario,
- // using the arguments var3 and var4 as applicable.
- }
- });
- }
- }
- });
- }
- // Writes to a div with id='message' on the page.
- function write(message){
- document.getElementById('message').innerText += message;
- }
Add Comment
Please, Sign In to add comment