Sending emails with new line characters "\n" in the body text #930
Unanswered
MaskellRichard
asked this question in
Q&A
Replies: 1 comment 1 reply
-
This is what body setter does: @body.setter
def body(self, value):
if self.__body:
if not value:
self.__body = ''
elif self.body_type == 'html':
soup = bs(self.__body, 'html.parser')
soup.body.insert(0, bs(value, 'html.parser'))
self.__body = str(soup)
else:
self.__body = ''.join((value, '\n', self.__body))
else:
self.__body = value
self._track_changes.add('body') As you see when it's html it's inserting the vale at position 0. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to send an email where the body text contains new line "\n" characters. The code that sets the body text is:
msg.body = requestString + "\n" + response
Whatever I do the emails body text has had the new line character replaced with a space character. I've confirmed this by copying the body text from the generated email (sent to my inbox) and pasting it into an appropriate development tool and viewing invisible characters.
Please don't tell me I don't need the newline character, it's not possible to change this.
The code reads a shared Office 365 Inbox, analyses the emails and sends out emails in response. The code has run for several years using EasyIMAP to read the emails from a shared Office365 mailbox. Microsoft recently breaking/withdrawing support of IMAP has prompted the migration to O365. Reading the emails with O365 is working fine. The old code uses SMTPLib to send the emails. I can stick with this so my need isn't urgent. However I don't trust Microsoft not to withdraw support for SMTP access at some time in the future and would rather fix this sooner than later.
Beta Was this translation helpful? Give feedback.
All reactions