SDK setup

Aspose.Email Cloud API

Aspose.Email Cloud API is a Cloud SDKs to send, receive, append, flag and convert cloud emails & support to create folder structure for email archiving in the cloud. This is easy to use and fast API, that doesn’t need to install the additional software. The API supports many programming languages, such as C#, Java, PHP, Python, Ruby & Typescript. To start working with Aspose.Email Cloud API you need to install a proper SDK. To know how to install SDK follow the instructions below.

Install SDK

SDK packages available at package repositories:

Use your package manager to install an SDK:

How to install SDK?

Use Package Manager:


PM> Install-Package Aspose.Email-Cloud 

Or .NET CLI:


dotnet add package Aspose.Email-Cloud

Or add a Package reference:


<PackageReference Include="Aspose.Email-Cloud"/>

First, add a repository:


<repository>

    <id>aspose-cloud</id>

    <name>Aspose.Cloud repository</name>

    <url>https://repository.aspose.cloud/repo</url>

</repository>

Then, add a dependency:


<dependency>

    <groupId>com.aspose</groupId>

    <artifactId>aspose-email-cloud</artifactId>

</dependency>

Use pip:


pip install aspose-email-cloud

Use gem:


gem install aspose_email_cloud

Use npm:


npm install @asposecloud/aspose-email-cloud --save

Use the composer:


composer require aspose/aspose-email-cloud

Get Your App Key and App SID

Before we will get our app Key and app SID, let’s find out: what is it and what are they for?

Simply put, app Key is a login and app SID is a password. You can create more than one app and each one will have it’s own app Key and app SID. You can use these apps within your services. Using the Aspose.Cloud Dashboard helps you to filter the statistics of your applications in My Usage section.

Here, you see the example of the apps’ statistics. In the APP column, you can see from which application was a request, also, there are details, size and sender’s IP address of a request.

todo:image_alt_text

App Key and app SID are used to get the temporary JWT token, which provides access to the API methods of Aspose.Email Cloud. These tokens can be seen in curl requests generated in the Swagger UI.

Our SDKs do not require you to receive these tokens again and again as they become obsolete. Instead, the EmailApi class stores app Key and app SID in itself and receive a token by itself. If the token is out of date, Aspose.Email SDKs automatically receive a new one.

To get your app Key and app SID follow these steps:

  1. Open the link of Aspose.Cloud Dashboard
  2. Sign in or sign up
  3. Open link
  4. Now you can create a new app or use First App, which is already created for you.
  5. Get App SID and App Key for your application to use them in SDK (you can also use them in our Swagger UI)

Aspose.Cloud Dashboard is a powerful tool where you can control your apps, storages and files.

Set up EmailApi Object

It is always convenient when everything is in one place. In our case, one of the main classes that will help us in development - EmailApi.

All API methods are available in one EmailApi class. To initialize EmailApi object we need to pass into it 2 required parameters: App Key and App SID (which are strings).

So, what are we waiting for, let’s create an instance of it:

How to set up EmailApi object?


using Aspose.Email.Cloud.Sdk.Api; //EmailApi class is here

using Aspose.Email.Cloud.Sdk.Model; //REST API models are here

using Aspose.Email.Cloud.Sdk.Model.Requests; //Request models are here (all API calls use corresponding request model class)

...

var appKey = "Your App Key";

var appSid = "Your App SID";

var emailApi = new EmailApi(appKey, appSid);


import com.aspose.email.cloud.sdk.invoker.ApiException;

import com.aspose.email.cloud.sdk.model.\*;

import com.aspose.email.cloud.sdk.model.requests.\*;

import com.aspose.email.cloud.sdk.api.\*;



...

EmailApi api = new EmailApi("Your App Key", "Your App SID");


from AsposeEmailCloudSdk import api, models

from AsposeEmailCloudSdk.models import requests

...

email_api = api.EmailApi("app_key", "app_sid")


require 'aspose-email-cloud'

include AsposeEmailCloud

...

@api = EmailApi.new('appKey', 'appSid')


import { EmailApi } from "@asposecloud/aspose-email-cloud/dist/src/api";

import \* as requests from "@asposecloud/aspose-email-cloud/dist/src/model/requests/requests";

import \* as model from "@asposecloud/aspose-email-cloud/dist/src/model/model";

...

var api = new EmailApi('appSid', 'appKey');


use Aspose\Email\EmailApi;

use Aspose\Email\Configuration;

use Aspose\Email\Model;

use Aspose\Email\Model\Requests;

...

$configuration = new Configuration();

$configuration

	->setAppKey("appKey")

	->setAppSid("appSid");

$api = new EmailApi(null, $configuration);

Our SDK automatically gets API token using your AppKey and AppSid. Also, it automatically gets a new token, if previous one is expired.

Check Everything Works

After setting up Aspose.Email Cloud API SDK, it’s time to start using it. The API has numerous functions for working with email messages, calendars, contacts, etc.. Also, the API includes AI functions such as theBusiness Card Recognition API and Name API. These features will facilitate and speed up the development of your application. 

Let’s call some SDK methods to see that everything set up properly. For example, you can easily convert an EML file to MSG format with our API.

EmailAPI object has a function to convert email messages, it’s called ConvertEmailAsync which converts email document to the specified format and returns as the file.

This function requires only one parameter — ConvertEmailRequest, which requests a model for conversion. To create a request you need to pass 2 required parameters: a file format you want to convert to (Enum: Eml, Msg, MsgUnicode, Mhtml, Html) and a file to upload for the further converting. 

How to convert EML to MSG?

Looks that everything is working. Now you can start the development!

Some Tips

We still advise you to read all the documentation in order to fully master this API.

You can use the trial version of the Aspose.Email Cloud API to try it out. The trial version has some restrictions, so, if you need the full power of our solution — we will be happy to see you as one of our customers.

Don’t be shy to ask questions on our free forum or the special paid forum for our customers, we will answer as soon as possible and help to solve your problems.

See More Tutorials

Take a look at other tutorials, you may find answers on your questions there: