First, it detects the encoding of the character string and adds it to the mime_part header. Since R finally has native UTF-8 on Windows since version 4.2 and UTF-8 is the most sensible default (Linux/MacOS), this encoding will always be chosen if possible.
The charset header is needed since some E-Mail software fail to display UTF-8 symbols correctly if it is missing (e.g. at least some Thunderbird versions and K9-Mail/Android). If you like, the code could be simplified by only allowing UTF-8 encoding for strings in sendmailR.
This MIME part allows adding inline HTML to E-Mails. This was up to now only possible by hacking the list object generated by mime_part(). Additionally, I added the possibility to add any HTML file as inline HTML. This way, the E-Mail body can be generated using knitr/rmarkdown and the resulting HTML file can be added without having to load it first (readlines or read_html). This function always expects UTF-8 encoding, which, I think, is reasonable.
I added documentation and tests for everything.
I hope you find this PR useful.
All the best
Alex
PS: If you consider these changes adequate, I would be happy if you add me as a contributor.
person("Alexander", "Bartel", role = "ctb", comment = c(ORCID = "0000-0002-1280-6138"))
Hi @olafmersmann,
This PR contains changes regarding content type and encoding.
Changes to mime_part.character solve the following problem: https://stackoverflow.com/questions/3528947/sendmailr-submit-encoded-message-to-local-smtp-server
First, it detects the encoding of the character string and adds it to the mime_part header. Since R finally has native UTF-8 on Windows since version 4.2 and UTF-8 is the most sensible default (Linux/MacOS), this encoding will always be chosen if possible.
The charset header is needed since some E-Mail software fail to display UTF-8 symbols correctly if it is missing (e.g. at least some Thunderbird versions and K9-Mail/Android). If you like, the code could be simplified by only allowing UTF-8 encoding for strings in sendmailR.
The new function mime_part_html() solves this problem: https://stackoverflow.com/questions/19844762/how-to-send-html-email-using-r https://stackoverflow.com/questions/21929170/email-dataframe-as-table-in-email-body-with-sendmailr https://stackoverflow.com/questions/3572607/sendmailr-part2-sending-files-as-mail-attachments
This MIME part allows adding inline HTML to E-Mails. This was up to now only possible by hacking the list object generated by mime_part(). Additionally, I added the possibility to add any HTML file as inline HTML. This way, the E-Mail body can be generated using knitr/rmarkdown and the resulting HTML file can be added without having to load it first (readlines or read_html). This function always expects UTF-8 encoding, which, I think, is reasonable.
I added documentation and tests for everything.
I hope you find this PR useful.
All the best Alex
PS: If you consider these changes adequate, I would be happy if you add me as a contributor.