Getting a email address from a Draft

Hi all,

I’m a little new to Javascript. How would I search a draft for any email address and then add the email address to a variable.

Thanks

I think this should help. If you only want the first e-mail address it will be at index 0 of the array.

const EMAILREGEX = /[A-Z0-9_!#$%&'*+\/=?`{|}~^.-]+@[A-Z0-9.-]+/gi;
let astrMails = draft.content.match(EMAILREGEX);
if(astrMails.length > 0) alert(astrMails.join("\n"));

Thank you so much for your help