Created
March 5, 2020 18:55
-
-
Save mmsharepoint/b74656a301b243865d3e6713a783d2d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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