|
1 | | -Aspose.Email Cloud is a REST API for creating email archiving applications that work with common email file formats. It lets developers manipulate message formats such as Outlook MSG, EML and MHT files. |
| 1 | +# Aspose.Email Cloud SDK for Node.Js [](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) [](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) [](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) [](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) |
| 2 | +This repository contains Aspose.Email Cloud SDK for Node.Js source code. This SDK allows you to work with Aspose.Email Cloud REST APIs in your Node.Js applications quickly and easily, with zero initial cost. |
2 | 3 |
|
3 | | -To use these SDKs, you will need App SID and App Key which can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/#/apps) (free registration in Aspose Cloud is required for this). |
| 4 | +[Aspose.Email Cloud home](https://products.aspose.cloud/email/family "Aspose.Email Cloud") |
| 5 | +[API Reference](https://apireference.aspose.cloud/email/) |
| 6 | + |
| 7 | +# Key features |
| 8 | + |
| 9 | +Aspose.Email Cloud is a REST API for creating email applications that work with standard email file formats. This SDK: |
| 10 | +- Lets developers manipulate different emails’ formats such as Outlook MSG, EML, VCard, and iCalendar files |
| 11 | +- Has a built-in email client |
| 12 | +- Supports AI functionalities: |
| 13 | + - The Business card recognition |
| 14 | + - The Name API for parsing and handling personal names |
4 | 15 |
|
5 | 16 | ## How to use the SDK? |
6 | | -The complete source code is available in the GIT repository. You can either directly use it in your project via source code or get [nmpjs distribution](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) (recommended). |
| 17 | +The complete source code is available in the GIT repository. |
| 18 | +Use reference documentation, available [here](doc/README.md). |
7 | 19 |
|
8 | | -### Install Aspose.Email for Cloud via NPM |
| 20 | +### Prerequisites |
| 21 | +To use this SDK, you need an App SID and an App Key; they can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/#/apps) (it requires free registration in Aspose Cloud for this). |
9 | 22 |
|
| 23 | +### Installation |
| 24 | +You can use it directly in your project via the source code or get a [npm package](https://www.npmjs.com/package/@asposecloud/aspose-email-cloud) |
10 | 25 | From the command line: |
11 | 26 |
|
12 | 27 | npm install @asposecloud/aspose-email-cloud --save |
13 | 28 |
|
| 29 | +### Usage examples |
| 30 | +To use the API, you should create an EmailApi object: |
| 31 | +```typescript |
| 32 | +var appKey = "Your App Key"; |
| 33 | +var appSid = "Your App SID"; |
| 34 | +var api = new EmailApi(appSid, appKey); |
| 35 | +``` |
| 36 | + |
| 37 | +#### Business cards recognition API |
| 38 | +See examples below: |
| 39 | + |
| 40 | +<details open> |
| 41 | + <summary>Parse business card images to VCard contact files</summary> |
| 42 | + |
| 43 | +```typescript |
| 44 | +var folder = 'some/folder/on/storage'; |
| 45 | +var storage = 'First Storage'; //Your storage name |
| 46 | +var imageData = fs.readFileSync('some/business/card/image/file/on/disk'); |
| 47 | +var storageFileName = 'someFileName.png'; //Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc. |
| 48 | +// Upload business card image to storage |
| 49 | +await api.uploadFile(new requests.UploadFileRequest(folder + '/' + storageFileName, imageData, storage)); |
| 50 | +var outFolder = 'some/other/folder/on/storage'; //Business card recognition results will be saved here |
| 51 | +await api.createFolder(new requests.CreateFolderRequest(outFolder, storage)); |
| 52 | +// Call business card recognition action |
| 53 | +var result = await api.aiBcrParseStorage( |
| 54 | + new requests.AiBcrParseStorageRequest(new models.AiBcrParseStorageRq( |
| 55 | + null, |
| 56 | + [new models.AiBcrImageStorageFile( //We can process multiple images in one request |
| 57 | + true, //the image contains only one business card (you can upload image with multiple cards on it) |
| 58 | + new models.StorageFileLocation(storage, folder, storageFileName))], |
| 59 | + new models.StorageFolderLocation(storage, outFolder)))); |
| 60 | +// Get file name from recognition result |
| 61 | +var contactFile = result.body.value[0]; //result.body.value can contain multiple files, if we sent multicard images or multiple images |
| 62 | +// You can download the VCard file, which produced by the recognition method ... |
| 63 | +var contactBinary = await api.downloadFile(new requests.DownloadFileRequest( |
| 64 | + contactFile.folderPath + '/' + contactFile.fileName, storage)); |
| 65 | +// ... and print it to console |
| 66 | +console.log(contactBinary.body.toString()); |
| 67 | +// Also, you can get VCard object properties’ list using Contact API |
| 68 | +var contactProperties = await api.getContactProperties(new requests.GetContactPropertiesRequest( |
| 69 | + 'vcard', contactFile.fileName, contactFile.folderPath, contactFile.storage)); |
| 70 | +//All VCard’s properties are available as a list. Complex properties are represented as hierarchical structures. |
| 71 | +//Let's print all primitive properties’ values: |
| 72 | +contactProperties.body.internalProperties |
| 73 | + .filter(property => property.type == 'PrimitiveObject') |
| 74 | + .map(property => property as models.PrimitiveObject) |
| 75 | + .forEach(property => |
| 76 | + console.log('Property name:' + property.name + ' value:' + property.value)); |
| 77 | +``` |
| 78 | +</details> |
| 79 | + |
| 80 | +<details> |
| 81 | + <summary>Parse images directly, without the using of a storage</summary> |
| 82 | + |
| 83 | +```typescript |
| 84 | +//Read image from file and convert it to Base64 string |
| 85 | +var imageData = fs.readFileSync('some/business/card/image/file/on/disk').toString('base64'); |
| 86 | +var result = await api.aiBcrParse(new requests.AiBcrParseRequest( |
| 87 | + new models.AiBcrBase64Rq(undefined, [new models.AiBcrBase64Image(true, imageData)]))); |
| 88 | +//Result contains all recognized VCard objects (only the one in our case) |
| 89 | +var contactProperties = result.body.value[0]; |
| 90 | +//VCard object is available as a list of properties, without any external calls: |
| 91 | +contactProperties.internalProperties |
| 92 | + .filter(property => property.type == 'PrimitiveObject') |
| 93 | + .map(property => property as models.PrimitiveObject) |
| 94 | + .forEach(property => |
| 95 | + console.log('Property name:' + property.name + ' value:' + property.value)); |
| 96 | +``` |
| 97 | +</details> |
| 98 | + |
| 99 | +#### Name API |
| 100 | +See examples below: |
| 101 | +<details open> |
| 102 | + <summary>Detect a person's gender by name</summary> |
| 103 | + |
| 104 | +```typescript |
| 105 | +var result = await api.aiNameGenderize(new requests.AiNameGenderizeRequest('John Cane')); |
| 106 | +//the result contains a list of hypothesis about a person's gender. |
| 107 | +//all hypothesis include score, so you can use the most scored version, which will be the first in a list: |
| 108 | +console.log(result.body.value[0].gender); //prints 'Male' |
| 109 | +``` |
| 110 | +</details> |
| 111 | + |
| 112 | +<details> |
| 113 | + <summary>Format person's name using defined format</summary> |
| 114 | + |
| 115 | +```typescript |
| 116 | +var result = await api.aiNameFormat(new requests.AiNameFormatRequest( |
| 117 | + 'Mr. John Michael Cane', undefined, undefined, undefined, undefined, '%t%L%f%m')); |
| 118 | +console.log(result.body.name); //prints 'Mr. Cane J. M.' |
| 119 | +``` |
| 120 | +</details> |
| 121 | + |
| 122 | +<details> |
| 123 | + <summary>Compare the names to find out if they belong to the same person or not</summary> |
| 124 | + |
| 125 | +```typescript |
| 126 | +var first = 'John Michael Cane'; |
| 127 | +var second = 'Cane J.'; |
| 128 | +var result = await api.aiNameMatch(new requests.AiNameMatchRequest( |
| 129 | + first, second)); |
| 130 | +console.log(result.body.similarity > 0.5); //prints 'true', names look similar |
| 131 | +``` |
| 132 | +</details> |
| 133 | + |
| 134 | +<details> |
| 135 | + <summary>Expand a person's name into a list of possible alternatives</summary> |
| 136 | + |
| 137 | +```typescript |
| 138 | +var result = await api.aiNameExpand(new requests.AiNameExpandRequest( |
| 139 | + 'Smith Bobby')); |
| 140 | +var names = result.body.names |
| 141 | + .map(weighted => weighted.name) |
| 142 | + .forEach(name => console.log(name)); //prints 'Mr. Smith', 'B. Smith', etc. |
| 143 | +``` |
| 144 | +</details> |
| 145 | + |
| 146 | +<details> |
| 147 | + <summary>Get k most probable names for given starting characters</summary> |
| 148 | + |
| 149 | +```typescript |
| 150 | +var prefix = 'Dav'; |
| 151 | +var result = await api.aiNameComplete(new requests.AiNameCompleteRequest( |
| 152 | + prefix)); |
| 153 | +var names = result.body.names |
| 154 | + .map(weighted => prefix + weighted.name) |
| 155 | + .forEach(name => console.log(name)); //prints 'David', 'Dave', 'Davis', etc. |
| 156 | +``` |
| 157 | +</details> |
| 158 | + |
| 159 | +<details> |
| 160 | + <summary>Parse out a person's name from an email address.</summary> |
| 161 | + |
| 162 | +```typescript |
| 163 | +var result = await api.aiNameParseEmailAddress(new requests.AiNameParseEmailAddressRequest( |
| 164 | + 'john-cane@gmail.com')); |
| 165 | +var extractedValues = result.body.value |
| 166 | + .map(extracted => extracted.name) |
| 167 | + .reduce((accumulator, value) => accumulator.concat(value)); |
| 168 | +var givenName = extractedValues.find(extracted => extracted.category == 'GivenName'); |
| 169 | +var surname = extractedValues.find(extracted => extracted.category == 'Surname'); |
| 170 | +console.log(givenName.value); // 'John' |
| 171 | +console.log(surname.value); // 'Cane' |
| 172 | +``` |
| 173 | +</details> |
| 174 | + |
14 | 175 | # Licensing |
15 | | -All Aspose.Email for Cloud SDKs, helper scripts and templates are licensed under [MIT License](LICENSE). |
| 176 | +All Aspose.Email Cloud SDKs, helper scripts and templates are licensed under [MIT License](LICENSE). |
16 | 177 |
|
17 | 178 | # Resources |
| 179 | ++ [**SDK reference documentation**](doc/README.md) |
18 | 180 | + [**Website**](https://www.aspose.cloud) |
19 | 181 | + [**Product Home**](https://products.aspose.cloud/Email/cloud) |
20 | 182 | + [**Documentation**](https://docs.aspose.cloud/display/Emailcloud/Home) |
|
0 commit comments