1. Products
  2.   Email
  3.   Python
  4.   Aspose.Email for Python via .NET

Aspose.Email for Python via .NET

 
 

Python API to Process Microsoft Outlook Emails

A Powerful Python Email Processing API that allows Adding Appointments, Extracting Email Contents as well as Creating, Editing and Converting Email Messages;

What is Aspose.Email for Python via .NET?

In today's fast-paced digital landscape, robust email management is critical for optimizing both business operations and individual productivity. Aspose.Email for Python via .NET is a comprehensive library that serves as a powerful solution for these challenges, empowering software developers with advanced email processing capabilities directly within their Python applications. By leveraging the strength of the .NET framework, this integration provides extensive support for working with diverse email formats, including Outlook MSG files, PST archives, and MIME messages. Developers can effortlessly parse, create, and manipulate emails, while built-in SMTP and POP3 client support simplifies the process of sending and receiving emails programmatically, ensuring reliable delivery for mission-critical applications.

The library excels in streamlining complex email extraction and manipulation tasks, significantly enhancing automation and workflow efficiency. With just a few lines of code, software developers can extract attachments, embed images, and perform seamless email conversion between various formats—such as converting emails to PDF for archiving or to HTML for web display. This versatility in handling email conversion tasks, combined with its ability to manage intricate email formats, unlocks new possibilities for data extraction and communication workflows. Aspose.Email for Python via .NET stands out as an indispensable tool for developers seeking to build sophisticated, automated, and highly efficient email management systems.

Previous Next

Getting Started with Aspose.Email for Python via .NET

The recommend way to install Aspose.Email for Python via .NET is using Pypi. Please use the following command for a smooth installation.

Install Aspose.Email for Python via .NET via Pypi

pip install Aspose.Email-for-Python-via-NET 
You can also download it directly from Aspose product page.

Create & Send Email Messages via Python API

Aspose.Email for Python via .NET makes it easy for software developers to create new email messages from the scratch with all basic email properties like From, To, Subject and body can be easily attached with the newly created mail message. The library has included several important features for handling email messages, such as creatig a new email with different properties, sending email messages to multiple recipients, request a read receipt, changing email addresses to a friendly name, setting Mail Body, setting HTML body, get or set an email’s date and time and many more.

Use multiple To, CC and BCC Addresses While Sending Email Messages via Python

eml = ae.MailMessage()
eml.subject = "New MailMessage created with Aspose.Email for Python"
eml.html_body = "This line is in bold  while this is normal text"
eml.from_address = "kashif.iqbal.aspose@domain.com"
eml.to.append(ae.MailAddress("to1@domain.com", "Recipient 1"))
eml.to.append(ae.MailAddress("to2@domain.com", "Recipient 2"))
eml.cc.append(ae.MailAddress("cc1@domain.com", "Recipient 3"))
eml.cc.append(ae.MailAddress("cc2@domain.com", "Recipient 4"))
# Send using Smtp Client
client = SmtpClient("smtp.gmail.com", 587, "username", "password")
client.send(eml)

Extract Email Message Contents via Python API

Aspose.Email for Python via .NET has provided support for extracting email messages contents from the emails inside Python applications. Software developers can easily display selected email messages contents on the screen with just couple of lines of Python code. The library has also provided support that allows software developers to extract email headers as well as decoded header values and uses it according to their own needs. The following example shows how to extract email headers and display it on the screen inside Python applications.

How to Extract Email Headers via Python API?

# Create MailMessage instance by loading an EML file
message = MailMessage.load(dataDir + "email-headers.eml");
print("\n\nheaders:\n\n")
# Print out all the headers
index = 0
for index, header in enumerate(message.headers):
print(header + " - ", end=" ")
print (message.headers.get(index))

Create & Manage Appointment inside Python Apps

Aspose.Email for Python via .NET is a very useful library for working with Outlook appointments. The library enables software developers to create new appointments and save it in ICS file format. You can set various properties for your appointment, such as Start Date, End Date, description, organizer, location, summary, and so on. You can easily open the appointment file in Microsoft Outlook or any program that can load an ICS file which will add the appointment information in the Outlook calendar. The library also supports loading an existing appointment in ICS format, reading and writing multiple events from ICS file, set status of appointment attendees and so on.

How to Write Multiple Events to ICS File via Python API?

saveOptions = IcsSaveOptions()

saveOptions.action = AppointmentAction.CREATE
writer = CalendarWriter(dataDir + "WriteMultipleEventsToICS_out.ics", saveOptions)
attendees = MailAddressCollection()
attendees.append("attendee@domain.com")
for i in range(10):
app = Appointment("Room 112", dt.datetime(2018, 5, 27, 22, 12, 11), dt.date(2018, 5, 28), "from@domain.com", attendees)
app.description = "Test body " + str(i)
app.summary = "Test summary:" + str(i)
writer.write(app)

Manage Outlook Storage Files (OST, PST) via Python

Aspose.Email for Python via .NET gives software developers the power to create and manage Outlook Storage Files (OST, PST) inside their own Python applications. There are many useful features available in the library for working with OST or PST files, such as creating new PST file and add subFolders to it, searching for messages, reading and Converting Outlook OST File, splitting and merging PST files, manage calendar items & contacts inside PST file, working with messages in a PST file, opening and reading Outlook PST File, get folders and fubFolders Information from PST and many more. The following example demonstrates how to merge into a single PST via Python API, 

How to Merge Multiple PSTs into a Single PST via Python API?

string dataDir = RunExamples.GetDataDir_Outlook();
string dst = dataDir + "Sub.pst";
totalAdded = 0;
try
{
using (PersonalStorage personalStorage = PersonalStorage.FromFile(dst))
{
// The events subscription is an optional step for the tracking process only.
personalStorage.StorageProcessed += PstMerge_OnStorageProcessed;
personalStorage.ItemMoved += PstMerge_OnItemMoved;
// Merges with the pst files that are located in separate folder. 
personalStorage.MergeWith(Directory.GetFiles(dataDir + @"MergePST\"));
Console.WriteLine("Total messages added: {0}", totalAdded);
} 
Console.WriteLine(Environment.NewLine + "PST merged successfully at " + dst);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose Email License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
} 
 English