Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ews2Case.py #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions workflows/Ews2Case.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf8 -*-

from bs4 import BeautifulSoup
import os, sys
import logging
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -147,17 +148,22 @@ def getEmailBody(email):
'Subject: ' + str(email.subject) + '\n\n')

body = email.text_body

#alternate way to get the body
#soup = BeautifulSoup(email.body, 'html.parser')
#try:
# #html email
# body = soup.body.text
#except AttributeError:
# #non html email
# body = soup.text

return ('```\n' + replyToInfo + body + '\n```')
#email.text_body should get the body either it is
#html or raw text
#unfortunately it is only supported with Exchange 2013
#so we need to get the body from another way

if body is None:
#alternate way to get the body
soup = BeautifulSoup(email.body, 'html.parser')
try:
#html email
body = soup.body.text
except AttributeError:
#non html email
body = soup.text

return ('```\n' + replyToInfo + str(body) + '\n```')

if __name__ == '__main__':
connectEws()