Last active
December 2, 2021 07:26
-
-
Save aspose-cloud/6ec28658aa5c23997911e5c1c61a3493 to your computer and use it in GitHub Desktop.
This Gist repository contains code snippet related to Aspose.Email Cloud SDK for Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aspose.Email-Cloud-SDK-Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var first = 'John Michael Cane'; | |
var second = 'Cane J.'; | |
var result = await api.aiNameMatch(new requests.AiNameMatchRequest( | |
first, second)); | |
console.log(result.body.similarity > 0.5); //prints 'true', names look similar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var result = await api.aiNameExpand(new requests.AiNameExpandRequest( | |
'Smith Bobby')); | |
var names = result.body.names | |
.map(weighted => weighted.name) | |
.forEach(name => console.log(name)); //prints 'Mr. Smith', 'B. Smith', etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var result = await api.aiNameParseEmailAddress(new requests.AiNameParseEmailAddressRequest( | |
'john-cane@gmail.com')); | |
var extractedValues = result.body.value | |
.map(extracted => extracted.name) | |
.reduce((accumulator, value) => accumulator.concat(value)); | |
var givenName = extractedValues.find(extracted => extracted.category == 'GivenName'); | |
var surname = extractedValues.find(extracted => extracted.category == 'Surname'); | |
console.log(givenName.value); // 'John' | |
console.log(surname.value); // 'Cane' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var calendar = new models.CalendarDto(); | |
calendar.attendees = [ | |
new models.MailAddress('Attendee Name', 'attendee@aspose.com', 'Accepted') | |
]; | |
calendar.description = 'Some description'; | |
calendar.summary = 'Some summary'; | |
calendar.organizer = new models.MailAddress('Organizer Name', 'organizer@aspose.com'); | |
calendar.startDate = getDate(undefined, 1); | |
calendar.endDate = getDate(calendar.startDate, 1); | |
calendar.location = 'Some location'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var fileName = "file.msg"; | |
var attachmentName = "attachment.txt"; | |
var folder = "file/location/on/storage"; | |
var attachmentFolder = "attachment/location/on/storage"; | |
var storage = "First storage"; | |
await api.addMapiAttachment(new requests.AddMapiAttachmentRequest( | |
fileName, attachmentName, new models.AddAttachmentRequest( | |
new models.StorageFolderLocation(storage, folder), | |
new models.StorageFolderLocation(storage, attachmentFolder)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Suppose that our IMAP account credentials located on storage in file "imap.account" | |
var imapAccount = "imap.account"; | |
var messageId = await api.appendEmailModelMessage(new requests.AppendEmailModelMessageRequest( | |
new models.AppendEmailModelRq(imapAccount, undefined, folderLocation, "INBOX", true, emailDto))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var email = new models.EmailDto(); | |
email.from = new models.MailAddress('From address', 'example@gmail.com'); | |
email.to = [new models.MailAddress('To address', 'to@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
var appendedMessageId = await api.appendEmailModelMessage(new requests.AppendEmailModelMessageRequest( | |
new models.AppendEmailModelRq( | |
imapAccount, undefined, | |
new models.StorageFolderLocation(storageName, accountFolder), | |
imapFolderName, true, email))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var folder = 'some/folder/on/storage'; | |
var storage = 'First Storage'; //Your storage name | |
var imageData = fs.readFileSync('some/business/card/image/file/on/disk'); | |
var storageFileName = 'someFileName.png'; //Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc. | |
// Upload Business card image to storage | |
await api.uploadFile(new requests.UploadFileRequest(folder + '/' + storageFileName, imageData, storage)); | |
var outFolder = 'some/other/folder/on/storage'; //Business card recognition results will be saved here | |
await api.createFolder(new requests.CreateFolderRequest(outFolder, storage)); | |
// Call Business card recognition action | |
var result = await api.aiBcrParseStorage( | |
new requests.AiBcrParseStorageRequest(new models.AiBcrParseStorageRq( | |
null, | |
[new models.AiBcrImageStorageFile( //We can process multiple images in one request | |
true, //the image contains only one business card (you can upload image with multiple cards on it) | |
new models.StorageFileLocation(storage, folder, storageFileName))], | |
new models.StorageFolderLocation(storage, outFolder)))); | |
// Get file name from recognition result | |
var contactFile = result.body.value[0]; //result.body.value can contain multiple files, if we sent multicard images or multiple images | |
// You can download the VCard file, which produced by the recognition method ... | |
var contactBinary = await api.downloadFile(new requests.DownloadFileRequest( | |
contactFile.folderPath + '/' + contactFile.fileName, storage)); | |
// ... and print it to console | |
console.log(contactBinary.body.toString()); | |
// Also, you can get VCard object properties’ list using Contact API | |
var contactProperties = await api.getContactProperties(new requests.GetContactPropertiesRequest( | |
'vcard', contactFile.fileName, contactFile.folderPath, contactFile.storage)); | |
//All VCard’s properties are available as a list. Complex properties are represented as hierarchical structures. | |
//Let's print all primitive properties’ values: | |
contactProperties.body.internalProperties | |
.filter(property => property.type == 'PrimitiveObject') | |
.map(property => property as models.PrimitiveObject) | |
.forEach(property => | |
console.log('Property name:' + property.name + ' value:' + property.value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Convert CalendarDto to AlternateView | |
var alternate = await api.convertCalendarModelToAlternate( | |
new requests.ConvertCalendarModelToAlternateRequest( | |
new models.CalendarDtoAlternateRq(calendar, 'Create'))); | |
//Create EmailDto with AlternateView | |
var email = new models.EmailDto(); | |
email.alternateViews = [alternate.body]; | |
email.from = new models.MailAddress('From address', 'organizer@aspose.com'); | |
email.to = [new models.MailAddress('To address', 'attendee@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
//Save EmailDto as EML file | |
var emailFile = 'email.eml'; | |
await api.saveEmailModel( | |
new requests.SaveEmailModelRequest( | |
'Eml', emailFile, new models.StorageModelRqOfEmailDto( | |
email, folderLocation))); | |
//Or Setup SMTP account to send email | |
var credentials = | |
new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password'); | |
var sendAccountDto = new models.EmailClientAccount( | |
'smtp.gmail.com', 465, 'SSLAuto', 'SMTP', credentials); | |
var smtpAccount = 'smtp.account'; | |
await api.saveEmailClientAccount(new requests.SaveEmailClientAccountRequest( | |
new models.StorageFileRqOfEmailClientAccount(sendAccountDto, | |
new models.StorageFileLocation(storage, folder, smtpAccount)))); | |
//And send it | |
await api.sendEmailModel(new requests.SendEmailModelRequest(new models.SendEmailModelRq( | |
smtpAccount, undefined, | |
new models.StorageFolderLocation(storage, folder), | |
email))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ics = await api.convertCalendar(new requests.ConvertCalendarRequest( | |
'Ics', mapi.body)); | |
//ICS is a text format. We can convert the buffer to a string and check that it | |
//contains specified location as a substring: | |
let icsString = ics.body.toString(); | |
expect(icsString).to.include(location); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mapi = await api.convertCalendarModelToFile(new requests.ConvertCalendarModelToFileRequest( | |
'Msg', calendarDto)); | |
//File content is available at mapi.body as a Buffer object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const surname = 'Cane'; | |
let contactDto = new models.ContactDto(); | |
contactDto.surname = surname; | |
contactDto.givenName = 'John'; | |
contactDto.gender = 'Male'; | |
contactDto.emailAddresses = [new models.EmailAddress(undefined, undefined, undefined, undefined, | |
'address@aspose.com')]; | |
contactDto.phoneNumbers = [new models.PhoneNumber(undefined, '+47234325344')]; | |
let mapi = await api.convertContactModelToFile(new requests.ConvertContactModelToFileRequest( | |
'Msg', contactDto)); | |
let vcard = await api.convertContact(new requests.ConvertContactRequest( | |
'VCard', 'Msg', mapi.body)); | |
let vcardString = vcard.body.toString(); | |
expect(vcardString).to.include(surname); | |
let dto = await api.getContactFileAsModel(new requests.GetContactFileAsModelRequest('VCard', vcard.body)); | |
expect(dto.body.surname).to.be.equal(surname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var convertedFile = await api.convertEmail( | |
new requests.ConvertEmailRequest( | |
'Msg', fs.readFileSync('email.eml'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const from = 'from@aspose.com'; | |
let emailDto = new models.EmailDto(); | |
emailDto.from = new models.MailAddress(undefined, from); | |
emailDto.to = [new models.MailAddress(undefined, 'to@aspose.com')]; | |
emailDto.subject = 'Some subject'; | |
emailDto.body = 'Some body'; | |
emailDto.date = new Date(); | |
let mapi = await api.convertEmailModelToFile(new requests.ConvertEmailModelToFileRequest( | |
'Msg', emailDto)); | |
let eml = await api.convertEmail(new requests.ConvertEmailRequest( | |
'Eml', mapi.body)); | |
let emlString = eml.body.toString(); | |
expect(emlString).to.include(from); | |
let dto = await api.getEmailFileAsModel(new requests.GetEmailFileAsModelRequest(eml.body)); | |
expect(dto.body.from.address).to.be.equal(from); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dto = await api.getCalendarFileAsModel(new requests.GetCalendarFileAsModelRequest(ics.body)); | |
expect(dto.body.location).to.be.equal(location); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var contact = new models.ContactDto(); | |
contact.gender = 'Male'; | |
contact.surname = 'Thomas'; | |
contact.givenName = 'Alex'; | |
contact.emailAddresses = [new models.EmailAddress( | |
new models.EnumWithCustomOfEmailAddressCategory('Work'), | |
'Alex Thomas', true, undefined, 'alex.thomas@work.com')]; | |
contact.phoneNumbers = [new models.PhoneNumber( | |
new models.EnumWithCustomOfPhoneNumberCategory('Work'), | |
'+49211424721', true)]; | |
// Save as .vcf: | |
var contactFile = 'contact.vcf'; | |
await api.saveContactModel( | |
new requests.SaveContactModelRequest( | |
'VCard', contactFile, new models.StorageModelRqOfContactDto( | |
contact, new models.StorageFolderLocation(storage, folder)))); | |
// Or as .msg: | |
var contactFileMsg = 'contact.msg'; | |
await api.saveContactModel( | |
new requests.SaveContactModelRequest( | |
'Msg', contactFileMsg, new models.StorageModelRqOfContactDto( | |
contact, new models.StorageFolderLocation(storage, folder)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var email = new models.EmailDto(); | |
email.from = new models.MailAddress('From address', 'organizer@aspose.com'); | |
email.to = [new models.MailAddress('To address', 'attendee@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
var storage = 'First storage'; | |
var folder = 'folder/on/storage'; | |
var folderLocation = new models.StorageFolderLocation(storage, folder); | |
var emailFile = 'email.eml'; | |
await api.saveEmailModel( | |
new requests.SaveEmailModelRequest( | |
'Eml', emailFile, new models.StorageModelRqOfEmailDto( | |
email, folderLocation))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calendar = new models.CalendarDto(); | |
calendar.attendees = [ | |
new models.MailAddress('Attendee Name', 'attendee@aspose.com', 'Accepted') | |
]; | |
calendar.description = 'Some description'; | |
calendar.summary = 'Some summary'; | |
calendar.organizer = new models.MailAddress('Organizer Name', 'organizer@aspose.com'); | |
calendar.startDate = getDate(undefined, 1); | |
calendar.endDate = getDate(calendar.startDate, 1); | |
calendar.location = 'Some location'; | |
var storage = 'First storage'; | |
var folder = 'folder/on/storage'; | |
var folderLocation = new models.StorageFolderLocation(storage, folder); | |
var calendarFile = 'calendar_file_name.ics'; | |
await api.saveCalendarModel( | |
new requests.SaveCalendarModelRequest( | |
calendarFile, | |
new models.StorageModelRqOfCalendarDto( | |
calendar, folderLocation))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var contact = new models.ContactDto(); | |
contact.gender = 'Male'; | |
contact.surname = 'Thomas'; | |
contact.givenName = 'Alex'; | |
contact.emailAddresses = [new models.EmailAddress( | |
new models.EnumWithCustomOfEmailAddressCategory('Work'), | |
'Alex Thomas', true, undefined, 'alex.thomas@work.com')]; | |
contact.phoneNumbers = [new models.PhoneNumber( | |
new models.EnumWithCustomOfPhoneNumberCategory('Work'), | |
'+49211424721', true)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await api.deleteEmailMessage(new requests.DeleteEmailMessageRequest(new models.DeleteMessageBaseRequest( | |
imapAccount, undefined, | |
new models.StorageFolderLocation(storageName, accountFolder), | |
id, true))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
api.deleteEmailMessage(new requests.DeleteEmailMessageRequest(new models.DeleteMessageBaseRequest( | |
'email.multi.account', undefined, | |
new models.StorageFolderLocation('First storage', 'email/account/location/on/storage'), | |
'<put your message identifier here>', true))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await api.deleteEmailThread(new requests.DeleteEmailThreadRequest(thread.id, | |
new models.DeleteEmailThreadAccountRq('email.account', undefined, | |
new models.StorageFolderLocation(storage, folder), 'INBOX'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var disposable = await api.isEmailAddressDisposable( | |
new requests.IsEmailAddressDisposableRequest('example@mailcatch.com')); | |
expect(disposable.body.value).toBeTrue(); | |
var regular = await api.isEmailAddressDisposable( | |
new requests.IsEmailAddressDisposableRequest('example@gmail.com')); | |
expect(regular.body.value).toBeFalse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var result = await api.aiNameGenderize(new requests.AiNameGenderizeRequest('John Cane')); | |
//the result contains a list of hypothesis about a person's gender. | |
//all hypothesis include score, so you can use the most scored version, which will be the first in a list: | |
console.log(result.body.value[0].gender); //prints 'Male' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var configs = await api.discoverEmailConfigOauth( | |
new requests.DiscoverEmailConfigOauthRequest( | |
new models.DiscoverEmailConfigOauth( | |
'example@gmail.com', true, undefined, | |
'client-id', 'client-secret', 'refresh-token'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var configs = await api.discoverEmailConfigPassword( | |
new requests.DiscoverEmailConfigPasswordRequest( | |
new models.DiscoverEmailConfigPassword( | |
'example@gmail.com', true, undefined, | |
'example.password'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var configs = await api.discoverEmailConfig( | |
new requests.DiscoverEmailConfigRequest( | |
'example@gmail.com')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calendarDto = await api.getCalendarModel(new requests.GetCalendarModelRequest( | |
calendarFile, folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = folder + '/' + calendarFile; | |
var downloaded = await api.downloadFile(new requests.DownloadFileRequest(path, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var contactDto = await api.getContactModel(new requests.GetContactModelRequest( | |
"VCard", "contact.vcf", folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = folder + '/' + contactFile; | |
var downloaded = await api.downloadFile(new requests.DownloadFileRequest(path, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = folder + '/' + emailFile; | |
var downloaded = await api.downloadFile(new requests.DownloadFileRequest(path, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var emailDto = await api.getEmailModel(new requests.GetEmailModelRequest( | |
"Eml", emailFile, folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var file = await api.getEmailAsFile( | |
new requests.GetEmailAsFileRequest( | |
emailFile, 'Msg', storage, folder)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var email = new models.EmailDto(); | |
email.from = new models.MailAddress('From address', 'from@aspose.com'); | |
email.to = [new models.MailAddress('To address', 'to@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
await api.appendEmailModelMessage(new requests.AppendEmailModelMessageRequest(new models.AppendEmailModelRq( | |
'emailAccount.account', undefined, | |
new models.StorageFolderLocation('First storage', 'emailAccount/location/on/storage'), | |
'INBOX', true, email))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
await api.setEmailReadFlag(new requests.SetEmailReadFlagRequest( | |
new models.SetMessageReadFlagAccountBaseRequest( | |
'email.account', undefined, | |
new models.StorageFolderLocation('First storage', 'email/account/location/on/storage'), | |
'<put your message identifier here>', true))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
//Get folders | |
var folders = await api.listEmailFolders(new requests.ListEmailFoldersRequest( | |
'email.account', undefined, 'First storage', 'email/account/location/on/storage')); | |
//Create folder | |
await api.createEmailFolder(new requests.CreateEmailFolderRequest( | |
new models.CreateFolderBaseRequest( | |
'email.account', undefined, | |
new models.StorageFolderLocation('First storage', 'email/account/location/on/storage'), | |
"NewFolderName"))); | |
//Delete folder | |
await api.deleteEmailFolder(new requests.DeleteEmailFolderRequest( | |
new models.DeleteFolderBaseRequest( | |
'email.account', undefined, | |
new models.StorageFolderLocation('First storage', 'email/account/location/on/storage'), | |
"NewFolderName", true))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var alternate = await api.convertCalendarModelToAlternate( | |
new requests.ConvertCalendarModelToAlternateRequest( | |
new models.CalendarDtoAlternateRq(calendar, 'Create'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var result = await api.aiNameFormat(new requests.AiNameFormatRequest( | |
'Mr. John Michael Cane', undefined, undefined, undefined, undefined, '%t%L%f%m')); | |
console.log(result.body.name); //prints 'Mr. Cane J. M.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
//Read image from file and convert it to Base64 string | |
var imageData = fs.readFileSync('some/business/card/image/file/on/disk').toString('base64'); | |
var result = await api.aiBcrParse(new requests.AiBcrParseRequest( | |
new models.AiBcrBase64Rq(undefined, [new models.AiBcrBase64Image(true, imageData)]))); | |
//Result contains all recognized VCard objects (only the one in our case) | |
var contactProperties = result.body.value[0]; | |
//VCard object is available as a list of properties, without any external calls: | |
contactProperties.internalProperties | |
.filter(property => property.type == 'PrimitiveObject') | |
.map(property => property as models.PrimitiveObject) | |
.forEach(property => | |
console.log('Property name:' + property.name + ' value:' + property.value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var folderLocation = new models.StorageFolderLocation(storage, folder); | |
var calendarFile = uuidv4() + '.ics'; | |
await api.saveCalendarModel( | |
new requests.SaveCalendarModelRequest( | |
calendarFile, | |
new models.StorageModelRqOfCalendarDto( | |
calendar, folderLocation))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var message = await api.fetchEmailModel(new requests.FetchEmailModelRequest( | |
'<put your message identifier here>', 'email.multi.account', null, | |
'First storage', 'email/account/location/on/storage')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var id = messages.body.value[0].messageId; | |
var message = await api.fetchEmailModel(new requests.FetchEmailModelRequest( | |
id, imapAccount, null, | |
storageName, accountFolder)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let thread = threads.body.value[0]; | |
let threadMessages = await api.fetchEmailThreadMessages(new requests.FetchEmailThreadMessagesRequest( | |
thread.id, 'email.account', undefined, 'INBOX', storage, folder)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var fileName = "file.msg"; | |
var folder = "file/location/on/storage"; | |
var storage = "First storage"; | |
var properties = await api.getMapiProperties(new requests.GetMapiPropertiesRequest( | |
fileName, folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calendarDtoList = await api.getCalendarModelList( | |
new requests.GetCalendarModelListRequest(folder, 10, 0, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let threads = await api.listEmailThreads(new requests.ListEmailThreadsRequest( | |
'INBOX', 'email.account', undefined, storage, folder, true, 200)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var contactDtoList = api.getContactModelList(new requests.GetContactModelListRequest( | |
"VCard", folder, storage, 10, 0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var fileName = 'file.msg'; | |
var storage = 'First storage'; | |
var folder = 'file/location/on/storage'; | |
await api.createMapi(new requests.CreateMapiRequest( | |
fileName, new models.HierarchicalObjectRequest( | |
new models.HierarchicalObject("IPM.Contact", undefined, [ | |
new models.PrimitiveObject("Tag:'PidTagMessageClass':0x1A:String", undefined, "IPM.Contact"), | |
new models.PrimitiveObject("Tag:'PidTagSubject':0x37:String"), | |
new models.PrimitiveObject("Tag:'PidTagSubjectPrefix':0x3D:String"), | |
new models.PrimitiveObject("Tag:'PidTagMessageFlags':0xE07:Integer32", undefined, "8"), | |
new models.PrimitiveObject("Tag:'PidTagNormalizedSubject':0xE1D:String"), | |
new models.PrimitiveObject("Tag:'PidTagBody':0x1000:String"), | |
new models.PrimitiveObject("Tag:'PidTagStoreSupportMask':0x340D:Integer32", undefined, "265849"), | |
new models.PrimitiveObject("Tag:'PidTagSurname':0x3A11:String", undefined, "Surname"), | |
new models.PrimitiveObject("Tag:'PidTagOtherTelephoneNumber':0x3A1F:String", undefined, "+79123456789"), | |
new models.PrimitiveObject("Tag:'':0x6662:Integer32", undefined, "0"), | |
new models.PrimitiveObject( | |
"Lid:'PidLidAddressBookProviderArrayType':0x8029:Integer32:00062004-0000-0000-c000-000000000046", | |
undefined, "1") | |
]), | |
new models.StorageFolderLocation(storage, folder)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await api.setEmailReadFlag(new requests.SetEmailReadFlagRequest( | |
new models.SetMessageReadFlagAccountBaseRequest(imapAccount, undefined, | |
new models.StorageFolderLocation(storageName, accountFolder), | |
id, true))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await api.setEmailThreadReadFlag(new requests.SetEmailThreadReadFlagRequest(thread.id, | |
new models.EmailThreadReadFlagRq('email.account', undefined, | |
new models.StorageFolderLocation(storage, folder), true, 'INBOX'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await api.moveEmailThread(new requests.MoveEmailThreadRequest(thread.id, | |
new models.MoveEmailThreadRq('email.account', undefined, new models.StorageFolderLocation(storage, folder), | |
'DESTINATION'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imageData = fs.readFileSync("/tmp/alex.png").toString('base64'); | |
var result = await api.aiBcrParseModel(new requests.AiBcrParseModelRequest( | |
new models.AiBcrBase64Rq( | |
undefined, [new models.AiBcrBase64Image(true, imageData)]))); | |
var contact = result.body.value[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var imageData = fs.readFileSync(imageFilePath).toString('base64'); | |
var result = await api.aiBcrParseModel(new requests.AiBcrParseModelRequest( | |
new models.AiBcrBase64Rq( | |
undefined, [new models.AiBcrBase64Image(true, imageData)]))); | |
var firstVCard = result.body.value[0]; | |
console.log(firstVCard.displayName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var prefix = 'Dav'; | |
var result = await api.aiNameComplete(new requests.AiNameCompleteRequest( | |
prefix)); | |
var names = result.body.names | |
.map(weighted => prefix + weighted.name) | |
.forEach(name => console.log(name)); //prints 'David', 'Dave', 'Davis', etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create email account object | |
var accountCredentials = | |
new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password'); | |
var account = new models.EmailClientAccount( | |
'smtp.gmail.com', | |
465, | |
'SSLAuto', | |
'SMTP', | |
accountCredentials); | |
var fileName = 'fileName.account'; | |
var storage = 'First storage'; | |
var folder = 'folder/on/storage'; | |
// Save account | |
await api.saveEmailClientAccount(new requests.SaveEmailClientAccountRequest( | |
new models.StorageFileRqOfEmailClientAccount( | |
account, new models.StorageFileLocation(storage, folder, fileName)))); | |
// Get email account from storage | |
var result = await api.getEmailClientAccount(new requests.GetEmailClientAccountRequest( | |
fileName, folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
// Create multi account object | |
var multiAccount = new models.EmailClientMultiAccount( | |
[new models.EmailClientAccount('imap.gmail.com', 993, 'SSLAuto', 'IMAP', | |
new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password')), | |
new models.EmailClientAccount('exchange.outlook.com', 443, 'SSLAuto', 'EWS', | |
new models.EmailClientAccountOauthCredentials( | |
'example@gmail.com', undefined, 'clientId', 'clientSecret', 'refreshToken'))], | |
new models.EmailClientAccount('smtp.gmail.com', 465, 'SSLAuto', 'SMTP', | |
new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password'))); | |
var fileName = 'fileName.multi.account'; | |
var storage = 'First storage'; | |
var folder = 'folder/on/storage'; | |
// Save multi account | |
await api.saveEmailClientMultiAccount(new requests.SaveEmailClientMultiAccountRequest( | |
new models.StorageFileRqOfEmailClientMultiAccount( | |
multiAccount, | |
new models.StorageFileLocation(storage, folder, fileName)))); | |
// Get multi account object from storage | |
var multiAccountFromStorage = await api.getEmailClientMultiAccount( | |
new requests.GetEmailClientMultiAccountRequest( | |
fileName, folder, storage)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var contactFile = uuidv4() + '.vcf'; | |
await api.saveContactModel( | |
new requests.SaveContactModelRequest( | |
'VCard', contactFile, new models.StorageModelRqOfContactDto( | |
contact, new models.StorageFolderLocation(storage, folder)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imapFolderName = 'INBOX'; | |
var messages = api.listEmailModels(new requests.ListEmailModelsRequest( | |
imapFolderName, "('From' Contains '.com')", imapAccount, undefined, | |
storageName, accountFolder, true)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var messages = api.listEmailModels(new requests.ListEmailModelsRequest( | |
'INBOX', "('From' Contains '.com')", 'email.multi.account', undefined, | |
'First storage', 'email/account/location/on/storage', true)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-node | |
var email = new models.EmailDto(); | |
email.from = new models.MailAddress('From address', 'from@aspose.com'); | |
email.to = [new models.MailAddress('To address', 'to@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
await api.sendEmailModel(new requests.SendEmailModelRequest(new models.SendEmailModelRq( | |
'emailAccount.account', undefined, | |
new models.StorageFolderLocation('First storage', 'emailAccount/location/on/storage'), | |
email))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var email = new models.EmailDto(); | |
email.from = new models.MailAddress('From address', 'example@gmail.com'); | |
email.to = [new models.MailAddress('To address', 'to@aspose.com')]; | |
email.subject = 'Some subject'; | |
email.body = 'Some body'; | |
await api.sendEmailModel(new requests.SendEmailModelRequest(new models.SendEmailModelRq( | |
smtpAccount, undefined, | |
new models.StorageFolderLocation(storageName, accountFolder), | |
email))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create email account object | |
var credentials = new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password'); | |
var receiveAccountDto = new models.EmailClientAccount( | |
'imap.gmail.com', 993, 'SSLAuto', 'IMAP', credentials); | |
var imapAccount = 'imap.account'; | |
var storageName = 'First storage'; | |
var accountFolder = 'folder/on/storage'; | |
// Save account | |
await api.saveEmailClientAccount( | |
new requests.SaveEmailClientAccountRequest( | |
new models.StorageFileRqOfEmailClientAccount( | |
receiveAccountDto, new models.StorageFileLocation( | |
storageName, accountFolder, imapAccount)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendAccountDto = new models.EmailClientAccount( | |
'smtp.gmail.com', 465, 'SSLAuto', 'SMTP', credentials); | |
var smtpAccount = 'smtp.account'; | |
// Save account | |
await api.saveEmailClientAccount(new requests.SaveEmailClientAccountRequest( | |
new models.StorageFileRqOfEmailClientAccount(sendAccountDto, | |
new models.StorageFileLocation(storageName, accountFolder, smtpAccount)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const accountCredentials = | |
new models.EmailClientAccountPasswordCredentials( | |
'example@gmail.com', undefined, 'password'); | |
const account = new models.EmailClientAccount('pop.gmail.com', 995, 'SSLAuto', 'POP3', | |
accountCredentials, | |
new models.StorageFileLocation(storage, folder, 'account.cache')); | |
const fileName = 'email.account'; | |
await api.saveEmailClientAccount(new requests.SaveEmailClientAccountRequest( | |
new models.StorageFileRqOfEmailClientAccount( | |
account, new models.StorageFileLocation(storage, folder, fileName)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment