Get Email body and set it as To Do Task content
This commit is contained in:
parent
e43f35704a
commit
0fbe0d1edc
|
@ -20,12 +20,17 @@ export interface ICreateTaskWebPartProps {
|
|||
export default class CreateTaskWebPart extends BaseClientSideWebPart<ICreateTaskWebPartProps> {
|
||||
|
||||
private _graphHttpClient: MSGraphClient;
|
||||
private _mailBody: string;
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.context.msGraphClientFactory.getClient().then(client => {
|
||||
this._graphHttpClient = client;
|
||||
resolve();
|
||||
const mailboxItem: Office.MessageRead = this.context.sdks.office.context.mailbox.item;
|
||||
mailboxItem.body.getAsync(Office.CoercionType.Text, (asyncResult: Office.AsyncResult<string>) => {
|
||||
this._mailBody = asyncResult.value;
|
||||
resolve();
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
reject(error);
|
||||
|
@ -43,7 +48,8 @@ export default class CreateTaskWebPart extends BaseClientSideWebPart<ICreateTask
|
|||
id: mailboxItem.itemId,
|
||||
subject: mailboxItem.subject,
|
||||
from: mailboxItem.from.emailAddress,
|
||||
to: mailboxItem.to[0].emailAddress
|
||||
to: mailboxItem.to[0].emailAddress,
|
||||
body: this._mailBody
|
||||
}
|
||||
};
|
||||
return context;
|
||||
|
|
|
@ -17,8 +17,6 @@ import {
|
|||
MessageBarType
|
||||
} from "office-ui-fabric-react";
|
||||
|
||||
import { MSGraphClient } from "@microsoft/sp-http";
|
||||
|
||||
export default class CreateTask extends React.Component<
|
||||
ICreateTaskProps,
|
||||
ICreateTaskState
|
||||
|
@ -30,10 +28,8 @@ export default class CreateTask extends React.Component<
|
|||
listItemAdded: false,
|
||||
selectedList: undefined,
|
||||
todoLists: [],
|
||||
newTaskTitle: this.props.context.item
|
||||
? this.props.context.item.subject
|
||||
: "New Task title here!",
|
||||
showSelectListError: false
|
||||
newTaskTitle: this.props.context.item ? this.props.context.item.subject : "New Task title here!",
|
||||
showSelectListError: false
|
||||
};
|
||||
|
||||
this._onDropdownChange = this._onDropdownChange.bind(this);
|
||||
|
@ -166,7 +162,7 @@ export default class CreateTask extends React.Component<
|
|||
status: "notStarted",
|
||||
title: taskTitle,
|
||||
body: {
|
||||
content: "You have a new task to do added from SPFx component!",
|
||||
content: this.props.context.item.body,
|
||||
contentType: "text",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -3,4 +3,5 @@ export interface IMailItem {
|
|||
subject: string;
|
||||
from: string;
|
||||
to: string;
|
||||
body: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue