Skip to content

Releases: aspose-email-cloud/aspose-email-cloud-ruby

20.1 - Model API

28 Jan 11:28
Compare
Choose a tag to compare

The page contains release notes for Aspose.Email Cloud 20.1 – API Reference

New features

Introducing new Model API for VCard, iCalendar and Email message

iCalendar is a MIME type which allows users to exchange and store calendaring and scheduling information such as journal entries, events, free/busy information and to-dos.
In the previous version were only property sets based API. For example, to create iCalendar file using .Net SDK you had to use the following code:

api.create_calendar(CreateCalendarRequestData.new(fileName, HierarchicalObjectRequest.new(
    HierarchicalObject.new('CALENDAR', nil, [
        PrimitiveObject.new('LOCATION', nil, 'location'),
        PrimitiveObject.new('STARTDATE', nil, startDate.strftime('%Y-%m-%d %H:%M:%SZ')),
        PrimitiveObject.new('ENDDATE', nil, endDate.strftime('%Y-%m-%d %H:%M:%SZ')),
        HierarchicalObject.new('ORGANIZER', nil, [
            PrimitiveObject.new('ADDRESS', nil, '[email protected]'),
            PrimitiveObject.new('DISPLAYNAME', nil, 'Piu Man')
        ]),
        HierarchicalObject.new('ATTENDEES', nil, [
            IndexedHierarchicalObject.new('ATTENDEE', nil, 0, [
                PrimitiveObject.new('ADDRESS', nil, '[email protected]'),
                PrimitiveObject.new('DISPLAYNAME', nil, 'Attendee Name')
            ])
        ])
    ]),
    StorageFolderLocation.new(@storage, @folder))))

In the current version, we simplified the work with iCalendar files. Now the same object can be represented by using new CalendarDto model:

calendar = CalendarDto.new
calendar.attendees = [MailAddress.new('Attendee Name', '[email protected]', 'Accepted')]
calendar.description = 'Some description'
calendar.summary = 'Some summary'
calendar.organizer = MailAddress.new('Organizer Name', '[email protected]', 'Accepted')
calendar.start_date = DateTime.now + 1
calendar.end_date = DateTime.now + 2
calendar.location = 'Some location'

You can use both ways to work with iCalendar files.

Model API does not have separate methods to operate with attachments. Attachments can be operated directly by transforming files to Base64 strings:

base64 = File.open('file/on/disk', 'rb') do |f|
    bin = f.read
    Base64.encode64(bin)
end
attachment = Attachment.new
attachment.base64_data = base64
attachment.name = 'attachment-name.txt'
calendar.attachments = [attachment]

More examples available on SDK wiki pages: .Net, Java, Python, Ruby, Typescript, PHP

Files conversion

Aspose.Email Cloud supports MSG, MHTM, HTML and EML file formats to store emails. Now new methods to convert such files are available. For example, to convert EML to MSG, you can use the following code:

email_file = api.convert_email(
    ConvertEmailRequestData.new('Msg', File.new('file/on/disk')))
converted = File.open(email_file, 'rb') do |f|
    bin = f.read
    # ...
end

More details on SDK wiki pages: .Net, Java, Python, Ruby, Typescript, PHP
Also, we added iCalendar to AlternateView converter. Now it can be properly attached to an email message:

alternate = api.convert_calendar_model_to_alternate(
    ConvertCalendarModelToAlternateRequestData.new(
        CalendarDtoAlternateRq.new(calendar, 'Create')))

SDK changes