import ReactNative from "react-native" ; param { string } recipient param { string } cc param { string } bcc param { string } subject param { string } body returns { Promise . < boolean > } export async function DraftEmail ( recipient ? , cc ? , bcc ? , subject ? , body ? ) { let url = "mailto:" ; if ( recipient ) { url += `${ encodeURI ( recipient ) }?` ; } if ( cc ) { url += `cc=${ encodeURIComponent ( cc ) }&` ; } if ( bcc ) { url += `bcc=${ encodeURIComponent ( bcc ) }&` ; } if ( subject ) { url += `subject=${ encodeURIComponent ( subject ) }&` ; } if ( body ) { url += `body=${ encodeURIComponent ( body ) }&` ; } url = url . slice ( 0 , - 1 ) ; if ( navigator && navigator . product === "ReactNative" ) { const Linking = require ( "react-native" ) . Linking ; return Linking . canOpenURL ( url ) . then ( supported => { if ( ! supported ) { return false ; } return Linking . openURL ( url ) . then ( ( ) => true ) ; } ) ; } if ( window && window . cordova ) { window . open ( url , "_system" ) ; return Promise . resolve ( true ) ; } if ( window ) { window . location . href = url ; return Promise . resolve ( true ) ; } return Promise . resolve ( false ) ; }