Create New Email in Python

Aspose.Email - Create New Email

To Create New Email using Aspose.Email Java for Python, Use following code.

Python Code

\# Create a instance of MailMessage class

message = self.MailMessage()

\# Set subject of the message

message.setSubject("New message created by Aspose.Email for Java")

mail_address = self.MailAddress

\# Set Html body

message.setHtmlBody("<b>This line is in bold.</b> <br/> <br/>" +

   "<font color=blue>This line is in blue color</font>")

\# Set sender information

message.setFrom(self.MailAddress("", "Sender Name", False))

\# Add TO recipients

message.getTo().addMailAddress(self.MailAddress("", "Recipient 1", False))

message.getTo().addMailAddress(self.MailAddress("", "Recipient 2", False))

\# Add CC recipients

message.getCC().addMailAddress(self.MailAddress("", "Recipient 3", False))

message.getCC().addMailAddress(self.MailAddress("", "Recipient 4", False))

\# Save message in EML and MSG formats

mail_message_save_type = self.MailMessageSaveType + "Message.eml", mail_message_save_type.getEmlFormat()) + "Message.msg", mail_message_save_type.getOutlookMessageFormat())

\# Display Status

print "Created email messages Successfully."

Download Running Code

Download Create New Email (Aspose.Email) from any of the below mentioned social coding sites: