Customizing Email Headers in Python

Aspose.Email - Customizing Email Headers

To Customize Email Headers 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")

\# 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 subject

message.setSubject("Customizing Email Headers")

\# Specify Date

timeZone = self.TimeZone

calendar = self.Calendar

calendar = calendar.getInstance(timeZone.getTimeZone("GMT"))

date = calendar.getTime()


\# Specify XMailer


\# Specify Secret Header

message.getHeaders().add("secret-header", "mystery")

\# Save message to disc

messageFormat= self.MessageFormat + "MsgHeaders.msg", messageFormat.getMsg())

\# Display Status

print "Customized message headers Successfully."

Download Running Code

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