Skip to content

[REF] Outlook: rework logging attachments #50

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juwu-odoo
Copy link

Currently logging emails with attachments can encounter several issues, including:

  • Error if there's a mismatch between the number of img tags and inline attachments
  • Images will sometimes be embedded in the wrong order
  • URL images are incorrectly overwritten

This commit refactors logRequest to be invariant to the email body and possible missing, extra, and/or out-of-order attachments. This is done by processing the .eml data directly and mapping attachments directly to img tags via contentId. Processing the .eml data is needed since the outlook-js API does not expose a method to fetch the attachment's contentId.

@juwu-odoo juwu-odoo force-pushed the outlook-ref-attachments-juwu branch 2 times, most recently from a76dfd1 to 079f87a Compare July 25, 2025 14:32
Currently logging emails with attachments can encounter several issues, including:
- Error if there's a mismatch between the number of img tags and inline attachments
- Images will sometimes be embedded in the wrong order
- URL images are incorrectly overwritten

This commit refactors logRequest to be invariant to the email body and possible missing, extra, and/or out-of-order attachments.
This is done by processing the .eml data directly and mapping attachments directly to img tags via contentId.
Processing the .eml data is needed since the outlook-js API does not expose a method to fetch the attachment's contentId.
@juwu-odoo juwu-odoo force-pushed the outlook-ref-attachments-juwu branch from 079f87a to 0836d2a Compare July 27, 2025 04:58
@@ -37,6 +37,7 @@
"fontawesome-4.7": "^4.7.0",
"node-forge": "^0.10.0",
"office-ui-fabric-react": "^7.139.0",
"postal-mime": "^1.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not a fan of adding dependencies :/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand as well, and I'm not a fan either. Unfortunately, parsing the eml data is necessary since there the native office api does not expose the attachments' contentId. postal-mime was the smallest and most focused library I found to get this working end-to-end.

@juwu-odoo juwu-odoo requested a review from std-odoo July 29, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants