Skip to content

Instantly share code, notes, and snippets.

@mmsharepoint
Created March 5, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmsharepoint/b74656a301b243865d3e6713a783d2d2 to your computer and use it in GitHub Desktop.
Save mmsharepoint/b74656a301b243865d3e6713a783d2d2 to your computer and use it in GitHub Desktop.
private getMetadata() {
this.state.graphController.retrieveMailMetadata(this.props.mail.id)
.then((response) => {
if (response !== null) {
this.setState((prevState: IOutlook2SharePointState, props: IOutlook2SharePointProps) => {
return {
mailMetadata: response
};
});
}
});
}
...
export default class GraphController {
private client: MSGraphClient;
private metadataExtensionName = 'mmsharepoint.onmicrosoft.MailStorage';
public retrieveMailMetadata(mailId: string): Promise<any> {
const apiUrl = `/me/messages/${mailId}`;
const expand = `Extensions($filter=id eq 'Microsoft.OutlookServices.OpenTypeExtension.${this.metadataExtensionName}')`;
return this.client
.api(apiUrl)
.version('v1.0')
.expand(expand)
.select('id,subject,extensions')
.get()
.then((response) => {
if (typeof response.extensions !== 'undefined' && response.extensions !== null) {
const metadata: IMailMetadata = {
extensionName: response.extensions[0].extensionName,
saveDisplayName: response.extensions[0].saveDisplayName,
saveUrl: response.extensions[0].saveUrl,
savedDate: new Date(response.extensions[0].savedDate)
};
return metadata;
}
else {
return null;
}
},
(error) => {
console.log(error);
return null;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment