Create New Email in Jython

Aspose.Email - Create New Email

To Create new Email using Aspose.Email Java for Jython, simply invoke CreateNewEmail module. Here you can see example code.

Jython Code

 from aspose-email import Settings

from import MailMessage

from import MailAddress

from import MailMessageSaveType

class CreateNewEmail:

    def __init__(self):

        dataDir = Settings.dataDir + 'ProgrammingEmail/CreateNewEmail/'

        # Create a instance of MailMessage class

        message = MailMessage()

        # Set subject of the message

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

        mail_address = 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(MailAddress("", "Sender Name", False))

        # Add TO recipients

        message.getTo().add(MailAddress("", "Recipient 1", False))

        message.getTo().add(MailAddress("", "Recipient 2", False))

        # Add CC recipients

        message.getCC().add(MailAddress("", "Recipient 3", False))

        message.getCC().add(MailAddress("", "Recipient 4", False))

        # Save message in EML and MSG formats

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

        # Display Status

        print "Created email messages Successfully."

if __name__ == '__main__':        


Download Running Code

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