Closed modernNeo closed 4 years ago
@modernNeo , you don't need copy any functions. That information is available at Message.html
and Message.text
(see https://github.com/coddingtonbear/django-mailbox/blob/26786a0b3200515d490ecb69e1bc5b86efcc0ffb/django_mailbox/models.py#L597-L613 )? Could you publish message which fail to parse?
@ad-m thanks for letting me know, I am still rather new at Python and I wasn't initially aware of what @property
meant 😅
As for publishing the message, I certainly can if you let me know what you want to to put here, the contents of Message
or Message.body
or Message.get_body()
or Message.get_email_object()
or something else entirely?
Do you also want to to put on here what it should parse the message to?
@ad-m any update on my question?
Just use message.html
.
Regarding to issue what does mean @property
let's see https://www.programiz.com/python-programming/property but it's out of scope of that library.
For my site, I am making announcements that display on the front page which are created from the emails that get sent to a gmail.
To accomplish this, I am performing the following code on the body so that I can print out each body in the html
message.body = get_body_from_message(message.get_email_object(), 'text', 'html').replace('\n', '').strip().replace("align=center", "")
I copied the
get_body_from_message
function from this line: https://github.com/coddingtonbear/django-mailbox/blob/master/django_mailbox/utils.py#L105In some cases, it works fine and successfully converts the body from its original form to plain text but in some cases, it is just returning a blank string. Am I doing this wrong?
if it helps, in my html I am traversing through the emails messages like so
{% for post in posts %}
<h3>{{post.subject}}</h3>
<p>Posted by {{post.from_header}} on {{post.processed}}</p>
{{post.body|safe|linebreaks}}
{% for attachment in post.attachments.all %}
<p></p>
<a href="{% get_static_prefix %}{{ attachment.document|cut:'documents/staticfiles/' }}">{{ attachment.document|cut:'documents/staticfiles/' }}</a><br>
{% endfor %}