Convert Emails to other Formats & Manage Attachments in Ruby

Jun 6 2014 3:02 AM

You can now convert email message to other formats like EML, MSG & MHT in a cloud using Aspose Cloud SDK in Ruby. Also, developers can download attachments from email messages and store them on a local disc or on Aspose storage. It is even possible to modify email message properties like From, To, and Subject. Below are the code samples for Converting Email to Other Formats and Download Attachment from Email.

 

Converting Email to Other Formats

 

require 'path/to/lib/asposecloudsdk'

app_sid = '****'

app_key = '****'

Aspose::Cloud::Common::AsposeApp.app_key = app_key

Aspose::Cloud::Common::AsposeApp.app_sid = app_sid

Aspose::Cloud::Common::AsposeApp.output_location = ''

Aspose::Cloud::Common::Product.set_base_product_uri('http://api.aspose.com/v1.1')

# Create Object of folder class

folder = Aspose::Cloud::AsposeStorage::Folder.new

folder.upload_file 'path/to/storage/email_test.eml'

# Create object of converter

con_obj = Aspose::Cloud::Email::Converter.new('path/to/storage/email_test.eml')

con_obj.convert('msg')

 

Download Attachment from Email

 

require 'path/to/lib/asposecloudsdk'

app_sid = '****'

app_key = '****'

Aspose::Cloud::Common::AsposeApp.app_key = app_key

Aspose::Cloud::Common::AsposeApp.app_sid = app_sid

Aspose::Cloud::Common::AsposeApp.output_location = ''

Aspose::Cloud::Common::Product.set_base_product_uri('http://api.aspose.com/v1.1')

# Create Object of folder class

folder = Aspose::Cloud::AsposeStorage::Folder.new

folder.upload_file 'path/to/storage/email_test.eml'

# Create object of email document

doc_obj = Aspose::Cloud::Email::Document.new('path/to/storage/email_test.eml')

result = doc_obj.get_attachment('attachment.jpg')