Convert DOTX to EML using Python
DOTX to EML conversion in your Python Applications without installing Microsoft Word® or Outlook.
Why to Convert DOTX to EML?
DOTX is a Microsoft Word template file format which is used to store a set of documents with predefined settings such as page layout, styles, and formatting. It is a great way to create a document with a consistent look and feel. On the other hand, EML is an email message format used by many email clients. It is a great way to store emails in a structured format. Converting DOTX to EML can be useful for archiving emails in a structured format or for creating a template for emails.
How Aspose.Total helps for DOTX to EML Conversion?
Aspose.Total for Python via .NET is a full package of various APIs dealing different formats including Email, Images and Microsoft Word formats. It includes Aspose.Words for Python via .NET and Aspose.Email for Python via .NET APIs that makes the conversion of DOTX to EML easy using Python. It’s a two step process, firstly load the Word file and render it into HTML via Aspose.Words for Python via .NET. Secondly load the converted HTML using Aspose.Email for Python via .NET and save it into EML format. This makes it easy for Python developers to add a DOTX to EML conversion feature within their application.
How to Convert DOTX to EML in Python
- Open the source DOTX file using Document class
- Call the
save
method while specifying output HTML file path and relevant HTML Save options as parameter. So your DOTX file is converted to HTML at the specified path - Now Load the saved HTML file using MailMessage.load
- Call the save method with relevant file path. So finally the DOTX is converted
Conversion Requirements
- For DOTX to EML conversion, Python 3.5 or later is required
- Reference APIs within the project directly from PyPI ( Aspose.Words and Aspose.Email )
- Or use the following pip command
pip install aspose.words
andpip install Aspose.Email-for-Python-via-NET
- Moreover, Microsoft Windows or Linux based OS (see more for Words and Email ) and for Linux check additional requirements for gcc and libpython and follow step by step instructions INSTALL
Save DOTX To EML in Python
import aspose.words as aw | |
doc = aw.Document("wordtoemail.docx") | |
doc.save("htmloutput.html") | |
msg= MailMessage.load(dir + "htmloutput.html") | |
msg.save("emloutput.eml", SaveOptions.default_eml) |