Save Message as Draft in Ruby

Aspose.Email - Save Message as Draft

To Save Message as Draft using Aspose.Email Java for Ruby, simply invoke SaveMessageAsDraft module. Here you can see example code.

Ruby Code

 data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'

\# Create a new instance of MailMessage class

message = Rjb::import('').new

\# Set subject of the message

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

mail_address = Rjb::import('')

\# 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("", "Sender Name", false))

\# Add TO recipients

message.getTo().add("", "Recipient 1", false))

message.getTo().add("", "Recipient 2", false))

\# Create an instance of MapiMessage and load the MailMessag instance into it

mapi_msg = Rjb::import('').fromMailMessage(message)

\# Set the MapiMessageFlags as UNSENT and FROMME

mapi_message_flags = Rjb::import('')

mapi_msg.setMessageFlags(mapi_message_flags.MSGFLAG_UNSENT || mapi_message_flags.MSGFLAG_FROMME)

\# Save the MapiMessage to disk + "New-Draft.msg")

\# Display Status

puts "Draft saved Successfully."

Download Running Code

Download Save Message as Draft (Aspose.Email) from any of the below mentioned social coding sites: