Emogrifier takes an HTML document and its associated CSS, and then inlines the styles by merging the CSS rules directly into the HTML tags. This is done by parsing the CSS, applying the styles to the respective elements, and then updating the HTML structure to include these styles. This ensures that the email will look as intended, regardless of the email client used to view it.