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 get an email's property by name 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";

/// <summary>
/// Read document property by name.
/// </summary>
/// <param name="name">File name. e.g. myEmail.msg</param>
/// <param name="propertyName">Property Name</param>
/// <param name="folder">Folder path.</param>
/// <param name="storage">The document storage.</param>
string name; string propertyName; string folder; string storage = "";

// Build URI to perform request. ServiceController is located in Aspose.Cloud.Common in .NET SDK Source code available at http://goo.gl/BftpIi
string apiUrl = string.Format(@"email/{0}/properties/{1}?storage={2}&folder={3}", name, propertyName, storage, folder);

JObject jObject = JObject.Parse(ServiceController.Get(apiUrl, appSid, appKey));
EmailPropertyResponse emailPropertyResponse = jObject.ToObject<EmailPropertyResponse>();
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"

''' <summary>
''' Read document property by name.
''' </summary>
''' <param name="name">File name. e.g. myEmail.msg</param>
''' <param name="propertyName">Property Name</param>
''' <param name="folder">Folder path.</param>
''' <param name="storage">The document storage.</param>
Dim name As String
Dim propertyName As String
Dim folder As String
Dim storage As String = ""

' Build URI to perform request. ServiceController is located in Aspose.Cloud.Common in .NET SDK Source code available at http://goo.gl/BftpIi
Dim apiUrl As String = String.Format("email/{0}/properties/{1}?storage={2}&folder={3}", name, propertyName, storage, folder)

Dim jObject__1 As JObject = JObject.Parse(ServiceController.[Get](apiUrl, appSid, appKey))
Dim emailPropertyResponse As EmailPropertyResponse = jObject__1.ToObject(Of EmailPropertyResponse)()
Wiki Markup
{card}
Wiki Markup
{card:label=Java}
Code Block
 
Wiki Markup
{card}
Wiki Markup
{card:label=PHP}
Code Block
 
Wiki Markup
{card}
Wiki Markup
{card:label=Ruby}
Code Block
 
Wiki Markup
{card}
Wiki Markup
{card:label=Python}
Code Block
 
Wiki Markup
{card}
Wiki Markup
{card:label=Perl}
Code Block
languageperl
 
Wiki Markup
{card}
Wiki Markup
{card:label=Node.js}
Code Block
languagejavascript
 
Wiki Markup
{card}
Wiki Markup
{card:label=C++}
Code Block
languagecpp
 
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;
String fileName = "Message.msg";
String propertyName = "Body";

//build URL
String strURL = EMAIL_URI + Uri.encode(fileName) + "/properties/" + Uri.encode(propertyName);
//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 = (String)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";
NSString *propertyName = @"Body";

//build URL
NSString *strURL = [NSString stringWithFormat:@"%@%@/properties/%@", EMAIL_URI,
                    [fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], propertyName];
//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/properties/Subject?appSID=XXXX&signature=XXXX" \
     -X GET \
     -H "Content-Type: application/json" \
     -H "Accept: application/json"
Expand
titleResponse
Code Block
{
  "EmailProperty": {
    "Link": {
      "Href": "http://api.aspose.cloud/v1.1/email/email_test.eml/documentproperties/Subject",
      "Rel": "self",
      "Type": null,
      "Title": null
    },
    "Name": "Subject",
    "Value": "This is a new subject"
  },
  "Code": 200,
  "Status": "OK"
}

SDK Examples

Panel
titleGet message property
Expand
titleC#
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-DotNET-CSharp-Email-Properties-GetMessageProperty-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-GetMessagePropertyByNameExample-GetMessagePropertyByNameExample.java"></script>
Expand
titlePHP
HTML
<script src="https://gist.github.com/a052f420f51722082cbb70d5e8d0f339.js?file=Examples-PHP-Email Properties-GetEmailProperty-.php"></script>
Expand
titleRuby
HTML
<script src="https://gist.github.com/aspose-email/3f41448648db89803193189f274722fa.js?file=Examples-Ruby-EmailProperties-read_document_property_by_name-.rb
"></script>
Expand
titlePython
HTML
<script src="https://gist.github.com/aspose-email/13478a90f198800bfcdafa983dbd0fcd.js?file=GetMessagePropertyByName.py"></script>
Expand
titleNode.js
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-Node.js-Email-Properties-GetMessageProperty-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-GetMessagePropertyByNameExample-GetMessagePropertyByNameExample.java"></script>
Expand
titleObjective C
HTML
<script src="https://gist.github.com/1779f6b192c8df02d5c083a6abedfb62.js?file=Examples-Objective C-Aspose.Email-Aspose.Email-EmailProperties-EmailProperty-GetEmailProperty.m"></script>
Expand
titlePerl
HTML
<script src="https://gist.github.com/aspose-email/838d7478e3720f941514d3d04417e82e.js?file=Examples-Perl-Email-Properties-GetMessageProperty-1.pl"></script>