Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Introduction 

Panel

This example allows you to retrieve an email's property using Aspose.Email for Cloud API in your applications. You can use our REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.

Resource

Panel

The following Aspose.Email for Cloud REST API resource has been used in the examples:properties

REST Methods References

Panel

We're referring some common methods in the REST examples to perform general operations. These methods can be found at the following page: REST API Methods

REST Examples

Panel
Wiki Markup
{composition-setup}{composition-setup}
Wiki Markup
{deck:id=1}
Wiki Markup
{card:label=C#}
Code Block
// Initialize variables being used
string appSid = "Get it from https://cloud.aspose.com";
string appKey = "Get it from https://cloud.aspose.com";

string name = "email-sample.msg";
string folder = "Email";
string storage = string.Empty;

// Build URI to perform request
string apiUrl = string.Format(@"email/{0}?storage={1}&folder={2}", name, storage, folder);

// Parse the json string to JObject. ServiceController is located in Aspose.Cloud.Common in .NET SDK Source code available at http://goo.gl/BftpIi
JObject jObject = JObject.Parse(ServiceController.Get(apiUrl, appSid, appKey));
EmailDocumentPropertiesResponse emailDocumentPropertiesResponse = jObject.ToObject<EmailDocumentPropertiesResponse>();
Wiki Markup
{card}
Wiki Markup
{card:label=VB.NET}
Code Block
' Initialize variables being used
Dim appSid As String = "Get it from https://cloud.aspose.com"
Dim appKey As String = "Get it from https://cloud.aspose.com"

Dim name As String = "email-sample.msg"
Dim folder As String = "Email"
Dim storage As String = String.Empty

' Build URI to perform request
Dim apiUrl As String = String.Format("email/{0}?storage={1}&folder={2}", name, storage, folder)

' Parse the json string to JObject. ServiceController is located in Aspose.Cloud.Common in .NET SDK Source code available at http://goo.gl/BftpIi
Dim jObject As JObject = JObject.Parse(ServiceController.Get(apiUrl, appSid, appKey))
Dim emailDocumentPropertiesResponse As EmailDocumentPropertiesResponse = jObject.ToObject(Of EmailDocumentPropertiesResponse)()
Wiki Markup
{card}
Wiki Markup
{card:label=Java}
Code Block
import java.io.*;
import com.aspose.cloud.common.*;

String appSID = "...";
String appKey = "...";

String method = "GET";
String requestUrl = "http://api.aspose.com/v1.1/email/Sample1.eml/properties/MessageId";
String signedUrl = Utils.Sign(requestUrl, appKey, appSID);

InputStream stream = Utils.ProcessCommand(signedUrl, method);
String response = Utils.StreamToString(stream);
stream.close();

Wiki Markup
{card}
Wiki Markup
{card:label=PHP}
Code Block
use Aspose\Cloud\Common\AsposeApp;
use Aspose\Cloud\Common\Utils;

AsposeApp::$appSID = "...";
AsposeApp::$appKey = "...";

$method = "GET";
$base_url = "http://api.aspose.com/v1.1";
$request_url = "$base_url/email/Sample1.eml/properties/MessageId";
$signed_url = Utils::sign($request_url);

$response = Utils::processCommand($signed_url, $method, "", "");
$response = json_decode($response);
var_dump($response);

Wiki Markup
{card}
Wiki Markup
{card:label=Ruby}
Code Block
app_sid = "..."
app_key = "..."
request_url = "http://api.aspose.com/v1.1/email/Sample1.eml/properties/MessageId"

Aspose::Cloud::Common::AsposeApp.new(app_sid, app_key)
signed_url = Aspose::Cloud::Common::Utils.sign(request_url)

response = RestClient.get(signed_url, :accept=>:json)
response = JSON.parse(response)
p response

Wiki Markup
{card}
Wiki Markup
{card:label=Python}
Code Block
import json
from aspose.cloud.common import *

AsposeApp.app_sid = "..."
AsposeApp.app_key = "..."

method = "GET"
request_url = "http://api.aspose.com/v1.1/email/Sample1.eml/properties/MessageId"
signed_url = Utils.sign(Utils(), request_url)

response = Utils.process_command(Utils(), signed_url, method, "", "")
response_json = json.loads(response)
print response_json

Wiki Markup
{card}
Wiki Markup
{card:label=Perl}
Code Block
languageperl
use Data::Dumper;

my $app_sid = "...";
my $app_key = "...";
my $base_url = "http://api.aspose.com/v1.1";

my $request_method = "GET";
my $request_url = "$base_url/email/Sample1.eml/properties/MessageId";
my $signed_url = Sign($request_url, $app_sid, $app_key);

my $result = ProcessCommand($request_method, $signed_url);
print Dumper($result);

Wiki Markup
{card}
Wiki Markup
{card:label=Node.js}
Code Block
languagejavascript
var appSID = "...";
var appKey = "...";
var base_url = "http://api.aspose.com/v1.1/";

var method = "GET";
var request_url = base_url + "email/Sample1.eml/properties/MessageId";
var signed_url = Sign(request_url, appSID, appKey);

ProcessCommand(
  method,
  signed_url,
  null,
  function(response) {
    console.log(JSON.stringify(response, null, 2));
  }
);

Wiki Markup
{card}
Wiki Markup
{card:label=C++}
Code Block
languagecpp
std::string app_sid = "...";
std::string app_key = "...";
std::string base_url = "http://api.aspose.com/v1.1/";

std::string method = "GET";
std::string request_url = base_url + "email/Sample1.eml/properties/MessageId";
std::string signed_url = sign(request_url, app_sid, app_key);

rapidjson::Document response = process_command(method, signed_url);
std::cout << "Status: " << response["Status"].GetString() << std::endl;
Wiki Markup
{card}
Wiki Markup
{card:label=Android}
Code Block
AsposeApp.setAppKeyAndAppSID("Get it from https://cloud.aspose.com", "Get it from https://cloud.aspose.com")
AsposeApp.setBaseProductURI("http://api.aspose.com/v1.1");

String EMAIL_URI = AsposeApp.BASE_PRODUCT_URI + "/email/";

String propertyValue = null;

//build URL
String strURL = EMAIL_URI + Uri.encode("Message.msg") + "/properties/" + Uri.encode("Body");
//sign URL
String signedURL = Utils.sign(strURL);
InputStream responseStream = Utils.processCommand(signedURL, "GET");
String jsonStr = Utils.streamToString(responseStream);

//Parsing JSON
Gson gson = new Gson();
EmailPropertyResponse emailPropertyResponse = gson.fromJson(jsonStr, EmailPropertyResponse.class);
if(emailPropertyResponse.getCode().equals("200") && emailPropertyResponse.getStatus().equals("OK")) {
    propertyValue = emailPropertyResponse.emailProperty.value;
}

Wiki Markup
{card}
Wiki Markup
{card:label=Objective C (iOS)}
Code Block
[ASPOSEApp setAppKey:@"Get it from https://cloud.aspose.com" andAppSID:@"Get it from https://cloud.aspose.com"];
[ASPOSEProduct setBaseProductUri:@"http://api.aspose.com/v1.1"];

NSString *EMAIL_URI = [[ASPOSEProduct baseProductUri] stringByAppendingString:@"/email/"];

NSObject *propertyValue = nil;
NSString *fileName = @"Self Assessment.eml";

//build URL
NSString *strURL = [NSString stringWithFormat:@"%@%@/properties/%@", EMAIL_URI,
                    [fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], @"Body"];
//sign URL
NSString *signedURL = [ASPOSEUtils sign:strURL];

NSData *responseData = [ASPOSEUtils processCommand:signedURL httpMethod:@"GET"];

//Parsing JSON
if(responseData) {
    NSError *error;
    ASPOSEEmailPropertyResponse *emailPropertyResponse = [[ASPOSEEmailPropertyResponse alloc] initWithData:responseData error:&error];
    if(!error && [emailPropertyResponse.code isEqualToString:@"200"] && [emailPropertyResponse.status isEqualToString:@"OK"]) {
        propertyValue = emailPropertyResponse.emailProperty.value;
    }
}

Wiki Markup
{card}
Wiki Markup
{deck}

SDK Source

The Aspose for Cloud SDKs can be downloaded from the following page: Available SDKs

cURL Example

Panel
bgColor#FFFFFF
Expand
titleRequest
Code Block
curl -v "http://api.aspose.cloud/v1.1/email/email_test.eml?appSID=XXXX&signature=XXXX" \
     -X GET \
     -H "Content-Type: application/json" \
     -H "Accept: application/json"
Expand
titleResponse
Code Block
Retrieved File

SDK Examples

Panel
titleRetrieve message property
Expand
titleC#
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-DotNET-CSharp-Email-Properties-RetrieveMessageProperties-1.cs"></script>
Expand
titleJava
HTML
<script src="https://gist.github.com/aspose-email/10428737982c525bf33b54ad9c27b707.js?file=Examples-JAVA-SDK-src-main-java-com-aspose-email-cloud-properties-RetrieveMessagePropertiesExample-RetrieveMessagePropertiesExample.java"></script>
Expand
titlePHP
HTML
<script src="https://gist.github.com/a052f420f51722082cbb70d5e8d0f339.js?file=Examples-PHP-Email Properties-GetDocument-.php"></script>
Expand
titleRuby
HTML
<script src="https://gist.github.com/aspose-email/3f41448648db89803193189f274722fa.js?file=Examples-Ruby-EmailProperties-get_mail_common_info-.rb"></script>
Expand
titlePython
HTML
<script src="https://gist.github.com/aspose-email/13478a90f198800bfcdafa983dbd0fcd.js?file=RetrieveMessageProperties.py"></script>
Expand
titleNode.js
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-Node.js-Email-Properties-RetrieveMessageProperties-1.js"></script>
Expand
titleAndroid
HTML
<script src="https://gist.github.com/aspose-email/95a576636fc5c03e126e2617c83ce117.js?file=Examples-Android-app-src-main-java-com-aspose-email-cloud-examples-working-properties-RetrieveMessagePropertiesExample-RetrieveMessagePropertiesExample.java"></script>
Expand
titleObjective C
HTML
<script src="https://gist.github.com/1779f6b192c8df02d5c083a6abedfb62.js?file=Examples-Objective C-Aspose.Email-Aspose.Email-EmailProperties-EmailProperty-GetDocument.m"></script>
Expand
titlePerl
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-Perl-Email-Properties-RetrieveMessageProperties-1.pl"></script>