Updated outlook.py to support writing also the mail text data to a temporary file with mkstemp. Also changed some details in saving the attachments which has been wrong up to now.
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2756 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
66faec4a38
commit
80ff9b8403
1 changed files with 9 additions and 4 deletions
|
@ -167,6 +167,7 @@ class OutlookCrawler(MailCrawler):
|
||||||
enc = None
|
enc = None
|
||||||
textType = "application/octet-stream"
|
textType = "application/octet-stream"
|
||||||
attachments = []
|
attachments = []
|
||||||
|
mailContent = ""
|
||||||
ident = None
|
ident = None
|
||||||
if (hasattr(mail, 'BodyFormat')):
|
if (hasattr(mail, 'BodyFormat')):
|
||||||
value = getattr(mail, 'BodyFormat')
|
value = getattr(mail, 'BodyFormat')
|
||||||
|
@ -186,14 +187,14 @@ class OutlookCrawler(MailCrawler):
|
||||||
mailContent = getattr(mail, 'HTMLBody')
|
mailContent = getattr(mail, 'HTMLBody')
|
||||||
textType = "text/html"
|
textType = "text/html"
|
||||||
else:
|
else:
|
||||||
mailContent = "Could not retrieve HTMLBody of mail"
|
mailContent = ""
|
||||||
textType = "text/html"
|
textType = "text/html"
|
||||||
else:
|
else:
|
||||||
#Could not determine BodyFormat. Try to retrieve plain text
|
#Could not determine BodyFormat. Try to retrieve plain text
|
||||||
if hasattr(mail, 'Body'):
|
if hasattr(mail, 'Body'):
|
||||||
mailContent = getattr(mail, 'Body')
|
mailContent = getattr(mail, 'Body')
|
||||||
else:
|
else:
|
||||||
mailContent = "Could not retrieve mail body"
|
mailContent = ""
|
||||||
if hasattr(mail, 'InternetCodepage'):
|
if hasattr(mail, 'InternetCodepage'):
|
||||||
Codepage = getattr(mail, 'InternetCodepage')
|
Codepage = getattr(mail, 'InternetCodepage')
|
||||||
if codepages.has_key(Codepage):
|
if codepages.has_key(Codepage):
|
||||||
|
@ -205,17 +206,21 @@ class OutlookCrawler(MailCrawler):
|
||||||
for item in range(1, len(attachedElems)+1):
|
for item in range(1, len(attachedElems)+1):
|
||||||
fileHandle, filePath = tempfile.mkstemp(prefix="outlook")
|
fileHandle, filePath = tempfile.mkstemp(prefix="outlook")
|
||||||
attachedItem = attachedElems.Item(item)
|
attachedItem = attachedElems.Item(item)
|
||||||
attachedItem.SaveAsFile(fileHandle)
|
attachedItem.SaveAsFile(filePath)
|
||||||
os.close(fileHandle)
|
os.close(fileHandle)
|
||||||
metadat = self.createMetadata(dict(filename=filePath))
|
metadat = self.createMetadata(dict(filename=filePath))
|
||||||
fileRes = FileResource(data=None,
|
fileRes = FileResource(data=None,
|
||||||
path=filePath,
|
path=filePath,
|
||||||
metadata=metadat)
|
metadata=metadat)
|
||||||
attachments.append(fileRes)
|
attachments.append(fileRes)
|
||||||
|
fileHandle, filePath = tempfile.mkstemp(prefix="olmail")
|
||||||
|
filePointer = os.fdopen(fileHandle, "w")
|
||||||
|
filePointer.write(mailContent)
|
||||||
|
filePointer.close()
|
||||||
resource = MailResource(data=mailContent,
|
resource = MailResource(data=mailContent,
|
||||||
contentType=textType,
|
contentType=textType,
|
||||||
encoding=enc,
|
encoding=enc,
|
||||||
path=None,
|
path=filePath,
|
||||||
application='outlook',
|
application='outlook',
|
||||||
identifier=ident,
|
identifier=ident,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
|
|
Loading…
Add table
Reference in a new issue