The setToAddresses() function sets the to field of the email. This function takes a string list as an input and hence we have created a string list object and added the to address to that string. … The setSubject() function sets the subject of the mail and the setHtmlBody() sets the body of the mail in HTML form