Manage Attachments in Email Message in Python

Aspose.Email - Manage Attachments in Email

To Manage Attachments in 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))

\# Adding attachment

\# Load an attachment

attachment = self.Attachment(self.dataDir + "1.txt")

\# Add attachment in instance of MailMessage class


\# Save message to disc

messageFormat = self.MessageFormat + "Add-Attachment.msg", messageFormat.getMsg())

\# Display Status

print "Added attachment successfully."

Download Running Code

Download Manage Attachments in Email Message (Aspose.Email) from any of the below mentioned social coding sites: