Last active
December 2, 2021 07:26
-
-
Save aspose-cloud/e50bc177cb788e499fd13c27b55d762e to your computer and use it in GitHub Desktop.
The GIST contains SDK Examples of Aspose.Email Cloud SDK for .NET.
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-.NET |
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-dotnet | |
// Initialization of properties of AddMapiAttachmentRequest | |
string documentFileName = "documentFileName"; | |
string attachmentFileName = "attachmentFileName"; | |
// Initialization of AddAttachmentRequest | |
AddAttachmentRequest attachmentRequest = new AddAttachmentRequest(); | |
// Storage folder location of document | |
attachmentRequest.AttachmentFolder = new StorageFolderLocation("storageName", "Attachment/Folder/path"); | |
// Storage folder location of an attachment | |
attachmentRequest.DocumentFolder = new StorageFolderLocation("storageName", "Document/Folder/path"); | |
AddMapiAttachmentRequest request = new AddMapiAttachmentRequest(documentFileName, attachmentFileName, attachmentRequest); | |
// Add an attachment to the document | |
emailApi.AddMapiAttachment(request); |
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 emailApi.AppendEmailModelMessageAsync(new AppendEmailModelMessageRequest( | |
new AppendEmailModelRq(imapAccount, null, 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 EmailDto | |
{ | |
From = new MailAddress("From address", "example@gmail.com", null), | |
To = new List<MailAddress> {new MailAddress("To address", "to@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
var appendedMessageId = await emailApi.AppendEmailModelMessageAsync(new AppendEmailModelMessageRequest( | |
new AppendEmailModelRq(imapAccount, null, | |
new 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
//Convert CalendarDto to AlternateView | |
var alternate = await emailApi.ConvertCalendarModelToAlternateAsync( | |
new ConvertCalendarModelToAlternateRequest( | |
new CalendarDtoAlternateRq(calendar, "Create", null))); | |
//Create EmailDto with AlternateView | |
var emailDto = new EmailDto | |
{ | |
AlternateViews = new List<AlternateView> | |
{ | |
alternate | |
}, | |
From = new MailAddress("From address", "organizer@aspose.com", "Accepted"), | |
To = new List<MailAddress> {new MailAddress("To address", "attendee@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
//Save EmailDto as EML file | |
var emailFile = "email.eml"; | |
await emailApi.SaveEmailModelAsync( | |
new SaveEmailModelRequest("Eml", emailFile, | |
new StorageModelRqOfEmailDto(emailDto, | |
folderLocation))); | |
//Or Setup SMTP account to send emailDto | |
var credentials = new EmailClientAccountPasswordCredentials | |
{ | |
Login = "example@gmail.com", | |
Password = "password" | |
}; | |
var sendAccountDto = new EmailClientAccount | |
{ | |
Host = "smtp.gmail.com", | |
Port = 465, | |
ProtocolType = "SMTP", | |
SecurityOptions = "SSLAuto", | |
Credentials = credentials | |
}; | |
var smtpAccount = "smtp.account"; | |
await emailApi.SaveEmailClientAccountAsync(new SaveEmailClientAccountRequest( | |
new StorageFileRqOfEmailClientAccount(sendAccountDto, | |
new StorageFileLocation(storage, folder, smtpAccount)))); | |
//And send it | |
await emailApi.SendEmailModelAsync(new SendEmailModelRequest( | |
new SendEmailModelRq(smtpAccount, null, | |
new StorageFolderLocation(storage, folder), | |
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 icsStream = await emailApi.ConvertCalendarAsync(new ConvertCalendarRequest( | |
"Ics", mapiStream)); | |
//icsStream can be saved as a calendar.ics file: | |
using (var file = File.OpenWrite("calendar.ics")) | |
{ | |
await icsStream.CopyToAsync(file); | |
} | |
icsStream.Seek(0, SeekOrigin.Begin); | |
//ICS is a text format. We can convert the stream to a string and check that it | |
//contains specified location as a substring: | |
using (var memoryStream = new MemoryStream()) | |
{ | |
await icsStream.CopyToAsync(memoryStream); | |
var icsString = Encoding.UTF8.GetString(memoryStream.ToArray()); | |
Assert.IsTrue(icsString.Contains(location)); | |
} | |
icsStream.Seek(0, SeekOrigin.Begin); |
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 mapiStream = await emailApi.ConvertCalendarModelToFileAsync( | |
new ConvertCalendarModelToFileRequest( | |
"Msg", calendarDto)); | |
//mapiStream can be saved as a calendar.msg file: | |
using (var file = File.OpenWrite("calendar.msg")) | |
{ | |
await mapiStream.CopyToAsync(file); | |
} | |
mapiStream.Seek(0, SeekOrigin.Begin); |
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 string surname = "Cane"; | |
//Create ContactDto: | |
var contactDto = new ContactDto | |
{ | |
Gender = "Male", | |
Surname = surname, | |
GivenName = "John", | |
EmailAddresses = new List<EmailAddress> | |
{ | |
new EmailAddress {Address = "address@aspose.com"} | |
}, | |
PhoneNumbers = new List<PhoneNumber> | |
{ | |
new PhoneNumber {Number = "+47235345346"} | |
} | |
}; | |
//Convert ContactDto to a Microsoft Outlook contact file: | |
var mapiStream = await emailApi.ConvertContactModelToFileAsync( | |
new ConvertContactModelToFileRequest( | |
"Msg", contactDto)); | |
//Convert from Microsoft Outlook contact to a VCard file: | |
var vcardStream = await emailApi.ConvertContactAsync(new ConvertContactRequest( | |
"VCard", "Msg", mapiStream)); | |
//Read VCard file to a string and check that it contains surname as a substring: | |
using (var memoryStream = new MemoryStream()) | |
{ | |
await vcardStream.CopyToAsync(memoryStream); | |
var vcardString = Encoding.UTF8.GetString(memoryStream.ToArray()); | |
Assert.IsTrue(vcardString.Contains(surname)); | |
} | |
vcardStream.Seek(0, SeekOrigin.Begin); | |
//Convert VCard file to a ContactDto object: | |
var dto = await emailApi.GetContactFileAsModelAsync( | |
new GetContactFileAsModelRequest("VCard", vcardStream)); | |
Assert.AreEqual(surname, dto.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
Stream convertedFile = await emailApi.ConvertEmailAsync( | |
new ConvertEmailRequest("Msg", File.OpenRead("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 string from = "from@aspose.com"; | |
var emailDto = new EmailDto | |
{ | |
From = new MailAddress{Address = from}, | |
To = new List<MailAddress>{new MailAddress{Address = "to@aspose.com"}}, | |
Subject = "Some subject", | |
Body = "Some body", | |
Date = DateTime.MinValue.AddDays(1) | |
}; | |
var mapiStream = await emailApi.ConvertEmailModelToFileAsync( | |
new ConvertEmailModelToFileRequest( | |
"Msg", emailDto)); | |
var emlStream = await emailApi.ConvertEmailAsync(new ConvertEmailRequest( | |
"Eml", mapiStream)); | |
using (var memoryStream = new MemoryStream()) | |
{ | |
await emlStream.CopyToAsync(memoryStream); | |
var emlString = Encoding.UTF8.GetString(memoryStream.ToArray()); | |
Assert.IsTrue(emlString.Contains(from)); | |
} | |
emlStream.Seek(0, SeekOrigin.Begin); | |
var dto = await emailApi.GetEmailFileAsModelAsync( | |
new GetEmailFileAsModelRequest(emlStream)); | |
Assert.AreEqual(from, dto.From.Address); |
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 dto = await emailApi.GetCalendarFileAsModelAsync( | |
new GetCalendarFileAsModelRequest(icsStream)); | |
Assert.AreEqual(location, dto.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 ContactDto | |
{ | |
Gender = "Male", | |
Surname = "Thomas", | |
GivenName = "Alex", | |
EmailAddresses = new List<EmailAddress> | |
{ | |
new EmailAddress | |
{ | |
Category = new EnumWithCustomOfEmailAddressCategory("Work", null), | |
Address = "alex.thomas@work.com", | |
Preferred = true, | |
DisplayName = "Alex Thomas" | |
} | |
}, | |
PhoneNumbers = new List<PhoneNumber> | |
{ | |
new PhoneNumber | |
{ | |
Category = new EnumWithCustomOfPhoneNumberCategory("Work", null), | |
Number = "+49211424721", | |
Preferred = true | |
} | |
} | |
}; | |
//Save as .vcf: | |
var contactFile = "contact.vcf"; | |
await emailApi.SaveContactModelAsync( | |
new SaveContactModelRequest( | |
"VCard", contactFile, | |
new StorageModelRqOfContactDto(contact, | |
new StorageFolderLocation(storage, folder)))); | |
//Or as .msg: | |
var contactFileMsg = "contact.msg"; | |
await emailApi.SaveContactModelAsync( | |
new SaveContactModelRequest( | |
"Msg", contactFileMsg, | |
new StorageModelRqOfContactDto(contact, | |
new 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 EmailDto | |
{ | |
From = new MailAddress("From address", "organizer@aspose.com", "Accepted"), | |
To = new List<MailAddress> {new MailAddress("To address", "attendee@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
var storage = "First storage"; | |
var folder = "folder/on/storage"; | |
var folderLocation = new StorageFolderLocation(storage, folder); | |
var emailFile = "email.eml"; | |
await emailApi.SaveEmailModelAsync( | |
new SaveEmailModelRequest("Eml", emailFile, | |
new 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 CalendarDto | |
{ | |
Attendees = new List<MailAddress> | |
{ | |
new MailAddress("Attendee Name", "attendee@aspose.com", "Accepted") | |
}, | |
Description = "Some description", | |
Summary = "Some summary", | |
Organizer = new MailAddress("Organizer Name", "organizer@aspose.com", null), | |
StartDate = DateTime.UtcNow.AddDays(1).AddHours(12), | |
EndDate = DateTime.UtcNow.AddDays(1).AddHours(13), | |
Location = "Some location" | |
}; | |
var storageName = "First storage"; | |
var folder = "folder/on/storage"; | |
var calendarFileName = $"calendar_file_name.ics"; | |
var folderLocation = new StorageFolderLocation(StorageName, folder); | |
await emailApi.SaveCalendarModelAsync( | |
new SaveCalendarModelRequest(calendarFileName, new 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-dotnet | |
var fileName = $"{Guid.NewGuid().ToString()}.ics"; | |
startDate = startDate ?? DateTime.UtcNow.Date.AddDays(1).AddHours(12); | |
var endDate = startDate.Value.AddHours(1); | |
var request = new CreateCalendarRequest(fileName, | |
new HierarchicalObjectRequest( | |
new HierarchicalObject("CALENDAR", null, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("LOCATION", null, "location"), | |
new PrimitiveObject("STARTDATE", null, startDate.Value.ToString("u")), | |
new PrimitiveObject("ENDDATE", null, endDate.ToString("u")), | |
new HierarchicalObject("ORGANIZER", null, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("ADDRESS", null, "organizer@aspose.com"), | |
new PrimitiveObject("DISPLAYNAME", null, "Piu Man") | |
}), | |
new HierarchicalObject("ATTENDEES", null, | |
new List<BaseObject> | |
{ | |
new IndexedHierarchicalObject("ATTENDEE", null, 0, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("ADDRESS", null, "attendee@aspose.com"), | |
new PrimitiveObject("DISPLAYNAME", null, | |
"Attendee Name") | |
}) | |
}) | |
}), new StorageFolderLocation(StorageName, folder))); | |
await emailApi.CreateCalendarAsync(request); |
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-dotnet | |
var contact = new ContactDto | |
{ | |
Gender = "Male", | |
Surname = "Thomas", | |
GivenName = "Alex", | |
EmailAddresses = new List<EmailAddress> | |
{ | |
new EmailAddress | |
{ | |
Category = new EnumWithCustomOfEmailAddressCategory("Work", null), | |
Address = "alex.thomas@work.com", | |
Preferred = true, | |
DisplayName = "Alex Thomas" | |
} | |
}, | |
PhoneNumbers = new List<PhoneNumber> | |
{ | |
new PhoneNumber | |
{ | |
Category = new EnumWithCustomOfPhoneNumberCategory("Work", null), | |
Number = "+49211424721", | |
Preferred = 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 emailApi.DeleteEmailMessageAsync(new DeleteEmailMessageRequest( | |
new DeleteMessageBaseRequest(imapAccount, null, | |
new 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-dotnet | |
await emailApi.DeleteEmailMessageAsync(new DeleteEmailMessageRequest( | |
new DeleteMessageBaseRequest("email.multi.account", null, | |
new 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 emailApi.DeleteEmailThreadAsync(new DeleteEmailThreadRequest(thread.Id, | |
new DeleteEmailThreadAccountRq("email.account", null, | |
new 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-dotnet | |
var disposable = await emailApi.IsEmailAddressDisposableAsync( | |
new IsEmailAddressDisposableRequest("example@mailcatch.com")); | |
Assert.IsTrue(disposable.Value); | |
var regular = await emailApi.IsEmailAddressDisposableAsync( | |
new IsEmailAddressDisposableRequest("example@gmail.com")); | |
Assert.IsFalse(regular.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
var configs = await emailApi.DiscoverEmailConfigOauthAsync( | |
new DiscoverEmailConfigOauthRequest( | |
new DiscoverEmailConfigOauth( | |
{ | |
Address = "example.login@gmail.com", | |
ClientId = "Your client id", | |
ClientSecret = "Your client secret", | |
RefreshToken = "Your refresh token", | |
FastProcessing = 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
var configs = await emailApi.DiscoverEmailConfigPasswordAsync( | |
new DiscoverEmailConfigPasswordRequest( | |
new DiscoverEmailConfigPassword | |
{ | |
Address = "example.login@gmail.com", | |
Password = "example.password", | |
FastProcessing = 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
var configs = await emailApi.DiscoverEmailConfigAsync( | |
new 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
CalendarDto calendarDto = await emailApi.GetCalendarModelAsync(new 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 fileStream = await emailApi.DownloadFileAsync(new DownloadFileRequest( | |
$"{folder}/{calendarFile}", 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 emailApi.GetContactModelAsync(new 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 fileStream = await emailApi.DownloadFileAsync(new DownloadFileRequest( | |
$"{folder}/{contactFile}", 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-dotnet | |
Stream file = await emailApi.GetEmailAsFileAsync( | |
new GetEmailAsFileRequest( | |
"file.eml", //File name on the Storage | |
"Msg", //desired format | |
"First Storage", //The Storage name | |
"folder/on/storage" //File location on the 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
Stream fileStream = await emailApi.DownloadFileAsync(new DownloadFileRequest( | |
$"{folder}/{emailFile}", 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 emailApi.GetEmailModelAsync(new 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
Stream file = await emailApi.GetEmailAsFileAsync( | |
new 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-dotnet | |
EmailApi emailApi = new EmailApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); | |
StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); | |
// Upload a business card image to storage | |
var storageName = "First Storage"; //Your storage name | |
var imageFileName = "someFileName.png"; //Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc. | |
using (var stream = File.OpenRead("some/business/card/image/file/on/disk")) | |
{ | |
await emailApi.UploadFileAsync(new UploadFileRequest(imageFileName, stream, storageName)); | |
} | |
var outFolder = "some/folder/on/storage"; //Business card recognition results will be saved here | |
await emailApi.CreateFolderAsync(new CreateFolderRequest(outFolder, storageName)); | |
// Call business card recognition action | |
var result = await emailApi.AiBcrParseStorageAsync(new AiBcrParseStorageRequest( | |
new AiBcrParseStorageRq(null, | |
new List<AiBcrImageStorageFile> //We can process multiple images in one | |
{new AiBcrImageStorageFile( | |
true, //Flag isSingle determines that image contains single VCard or more. | |
//Only single VCard on image variant is supported in current version. | |
new StorageFileLocation(storageName, string.Empty, imageFileName))}, | |
new StorageFolderLocation(storageName, outFolder)))); | |
// Get file name from a recognition result | |
var contactFile = result.Value.First(); //result.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 ... | |
using (var contactFileStream = await emailApi.DownloadFileAsync(new DownloadFileRequest( | |
$"{contactFile.FolderPath}/{contactFile.FileName}", contactFile.Storage))) | |
//... and save it to the "contact.vcf" file | |
using (var fileStream = File.Create("path/to/contact.vcf")) | |
{ | |
contactFileStream.CopyTo(fileStream); | |
} | |
// Also, you can get VCard object properties’ list using Contact API | |
var contactProperties = await emailApi.GetContactPropertiesAsync(new 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: | |
var primitiveProperties = contactProperties.InternalProperties | |
.Where(property => property is PrimitiveObject) | |
.Select(property => property as PrimitiveObject) | |
.ToList(); | |
foreach(var primitiveProperty in primitiveProperties) | |
{ | |
System.Console.WriteLine($"Property name: {primitiveProperty.Name}, value: {primitiveProperty.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-dotnet | |
var calendar = new CalendarDto | |
{ | |
Attendees = new List<MailAddress>{new MailAddress("Attendee Name", "attendee@aspose.com", null)}, | |
Organizer = new MailAddress("Organizer Name", "organizer@aspose.com", null), | |
StartDate = startDate, | |
EndDate = endDate, | |
Location = "location" | |
}; | |
CalendarDto model |
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-dotnet | |
var email = new EmailDto | |
{ | |
From = new MailAddress("From address", "from@aspose.com", null), | |
To = new List<MailAddress> {new MailAddress("To address", "to@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
var messageId = await emailApi.AppendEmailModelMessageAsync(new AppendEmailModelMessageRequest(new AppendEmailModelRq( | |
"emailAccount.account", null, | |
new 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-dotnet | |
await emailApi.SetEmailReadFlagAsync(new SetEmailReadFlagRequest( | |
new SetMessageReadFlagAccountBaseRequest( | |
"email.account", null, | |
new 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-dotnet | |
//Get folders | |
var folders = await emailApi.ListEmailFoldersAsync(new ListEmailFoldersRequest( | |
"email.account", null, "First storage", "email/account/location/on/storage")); | |
//Create folder | |
await emailApi.CreateEmailFolderAsync(new CreateEmailFolderRequest( | |
new CreateFolderBaseRequest( | |
"email.account", null, | |
new StorageFolderLocation("First storage", "email/account/location/on/storage"), | |
"NewFolderName", null))); | |
//Delete folder | |
await emailApi.DeleteEmailFolderAsync(new DeleteEmailFolderRequest( | |
new DeleteFolderBaseRequest( | |
"email.account", null, | |
new 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-dotnet | |
const string first = "John Michael Cane"; | |
const string second = "Cane J."; | |
var result = await emailApi.AiNameMatchAsync( | |
new AiNameMatchRequest(first, second)); | |
System.Console.WriteLine(result.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-dotnet | |
var alternate = await emailApi.ConvertCalendarModelToAlternateAsync( | |
new ConvertCalendarModelToAlternateRequest( | |
new CalendarDtoAlternateRq(calendar, "Create", null))); |
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-dotnet | |
var calendar = new CalendarDto | |
{ | |
Attendees = new List<MailAddress> | |
{ | |
new MailAddress("Attendee Name", "attendee@aspose.com", "Accepted") | |
}, | |
Description = "Some description", | |
Summary = "Some summary", | |
Organizer = new MailAddress("Organizer Name", "organizer@aspose.com", null), | |
StartDate = DateTime.UtcNow.AddDays(1).AddHours(12), | |
EndDate = DateTime.UtcNow.AddDays(1).AddHours(13), | |
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-dotnet | |
var contact = new ContactDto | |
{ | |
Gender = "Male", | |
Surname = "Thomas", | |
GivenName = "Alex", | |
EmailAddresses = new List<EmailAddress> | |
{ | |
new EmailAddress | |
{ | |
Category = new EnumWithCustomOfEmailAddressCategory("Work", null), | |
Address = "alex.thomas@work.com", | |
Preferred = true, | |
DisplayName = "Alex Thomas" | |
} | |
}, | |
PhoneNumbers = new List<PhoneNumber> | |
{ | |
new PhoneNumber | |
{ | |
Category = new EnumWithCustomOfPhoneNumberCategory("Work", null), | |
Number = "+49211424721", | |
Preferred = 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-dotnet | |
var email = new EmailDto | |
{ | |
AlternateViews = new List<AlternateView> {alternate}, | |
From = new MailAddress("From address", "organizer@aspose.com", "Accepted"), | |
To = new List<MailAddress> {new MailAddress("To address", "attendee@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; |
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-dotnet | |
var fileName = $"{Guid.NewGuid().ToString()}.ics"; | |
startDate = startDate ?? DateTime.UtcNow.Date.AddDays(1).AddHours(12); | |
var endDate = startDate.Value.AddHours(1); | |
var request = new CreateCalendarRequest(fileName, | |
new HierarchicalObjectRequest( | |
new HierarchicalObject("CALENDAR", null, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("LOCATION", null, "location"), | |
new PrimitiveObject("STARTDATE", null, startDate.Value.ToString("u")), | |
new PrimitiveObject("ENDDATE", null, endDate.ToString("u")), | |
new HierarchicalObject("ORGANIZER", null, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("ADDRESS", null, "organizer@aspose.com"), | |
new PrimitiveObject("DISPLAYNAME", null, "Piu Man") | |
}), | |
new HierarchicalObject("ATTENDEES", null, | |
new List<BaseObject> | |
{ | |
new IndexedHierarchicalObject("ATTENDEE", null, 0, | |
new List<BaseObject> | |
{ | |
new PrimitiveObject("ADDRESS", null, "attendee@aspose.com"), | |
new PrimitiveObject("DISPLAYNAME", null, | |
"Attendee Name") | |
}) | |
}) | |
}), new StorageFolderLocation(StorageName, folder))); | |
await emailApi.CreateCalendarAsync(request); |
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-dotnet | |
var name = "John Cane"; | |
var result = await emailApi.AiNameGenderizeAsync( | |
new AiNameGenderizeRequest(name)); | |
// the result contains a list of hypothesis about a person's gender. | |
// based on hypothesis score, most scored version will be the first in list | |
System.Console.WriteLine(result.Value.First().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
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet | |
const string name = "Smith Bobby"; | |
var result = await emailApi.AiNameExpandAsync( | |
new AiNameExpandRequest(name)); | |
var expandedNames = result | |
.Names | |
.Select(weightedName => weightedName.Name) | |
.ToList(); | |
foreach(var expandedName in expandedNames) | |
{ | |
System.Console.WriteLine(expandedName); //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-dotnet | |
var result = await emailApi.AiNameFormatAsync( | |
new AiNameFormatRequest( | |
"Mr. John Michael Cane", | |
format:"%t%L%f%m")); | |
System.Console.WriteLine(result.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-dotnet | |
const string prefix = "Dav"; | |
var result = await emailApi.AiNameCompleteAsync( | |
new AiNameCompleteRequest(prefix)); | |
var names = result.Names | |
.Select(weightedName => $"{prefix}{weightedName.Name}") | |
.ToList(); | |
foreach(var name in names) | |
{ | |
System.Console.WriteLine(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
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet | |
var bytes = File.ReadAllBytes(imageFilePath); | |
var imageBase64 = Convert.ToBase64String(bytes); | |
var result = await emailApi.AiBcrParseModelAsync( | |
new AiBcrParseModelRequest( | |
new AiBcrBase64Rq( | |
null, | |
new List<AiBcrBase64Image> | |
{ | |
new AiBcrBase64Image(true, imageBase64) | |
}))); | |
ContactDto firstVCard = result.Value.First(); | |
System.Console.WriteLine(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-dotnet | |
EmailApi emailApi = new EmailApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); | |
StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); | |
//Read image from file and convert it to Base64 string | |
var bytes = File.ReadAllBytes("some/business/card/image/file/on/disk"); | |
var base64Image = Convert.ToBase64String(bytes); | |
var result = await emailApi.AiBcrParseAsync(new AiBcrParseRequest(new AiBcrBase64Rq(null, | |
new List<AiBcrBase64Image> {new AiBcrBase64Image(true, base64Image)}))); | |
//Result contains all recognized VCard objects (only the one in our case) | |
var contactProperties = result.Value.First(); | |
//VCard object is available as a list of properties, without any external calls: | |
var primitiveProperties = contactProperties.InternalProperties | |
.Where(property => property is PrimitiveObject) | |
.Select(property => property as PrimitiveObject) | |
.ToList(); | |
foreach(var primitiveProperty in primitiveProperties) | |
{ | |
System.Console.WriteLine($"Property name: {primitiveProperty.Name}, value: {primitiveProperty.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-dotnet | |
const string address = "john-cane@gmail.com"; | |
var result = await emailApi.AiNameParseEmailAddressAsync( | |
new AiNameParseEmailAddressRequest(address)); | |
var extractedValues = result.Value | |
.SelectMany(value => value.Name) | |
.ToList(); | |
var givenName = extractedValues.First(value => value.Category == "GivenName"); | |
var surName = extractedValues.First(value => value.Category == "Surname"); | |
System.Console.WriteLine(givenName.Value); // "John" | |
System.Console.WriteLine(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-dotnet | |
var calendarFileName = $"{Guid.NewGuid()}.ics"; | |
var folderLocation = new StorageFolderLocation(StorageName, folder); | |
await emailApi.SaveCalendarModelAsync( | |
new SaveCalendarModelRequest(calendarFileName, new 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-dotnet | |
var contactFile = $"{Guid.NewGuid().ToString()}.vcf"; | |
await emailApi.SaveContactModelAsync( | |
new SaveContactModelRequest( | |
"VCard", contactFile, | |
new StorageModelRqOfContactDto(contact, | |
new StorageFolderLocation(StorageName, 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-dotnet | |
var emailFile = $"{Guid.NewGuid().ToString()}.eml"; | |
await emailApi.SaveEmailModelAsync( | |
new SaveEmailModelRequest("Eml", emailFile, | |
new 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
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet | |
//First, if there is no email client account configuration on storage: | |
//Create an IMAP account | |
var imapFile = $"{Guid.NewGuid().ToString()}.account"; | |
var imap = new SaveMailAccountRequest( | |
new SaveEmailAccountRequest( | |
"imap.aspose.com", 993, "organizer@aspose.com", "Auto", "IMAP", "IMAP account", | |
new StorageFileLocation(StorageName, folder, imapFile), "OrganizerPassword")); | |
await emailApi.SaveMailAccountAsync(imap); | |
//Create a SMTP account | |
var smtpFile = $"{Guid.NewGuid().ToString()}.account"; | |
var smtp = new SaveMailAccountRequest( | |
new SaveEmailAccountRequest( | |
"smtp.aspose.com", 465, "organizer@aspose.com", "Auto", "SMTP", "SMTP account", | |
new StorageFileLocation(StorageName, folder, smtpFile), "OrganizerPassword")); | |
await emailApi.SaveMailAccountAsync(smtp); | |
//Then, send the email | |
await emailApi.SendEmailModelAsync( | |
new SendEmailModelRequest( | |
new SendEmailModelRq( | |
imapFile, | |
smtpFile, | |
new StorageFolderLocation(StorageName, 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
// For complete examples and data files, please go to https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet | |
Stream convertedFile = await emailApi.ConvertEmailAsync( | |
new ConvertEmailRequest("Msg", File.OpenRead("eml/file/on/disk"))); |
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-dotnet | |
var message = await emailApi.FetchEmailModelAsync(new 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.Value.First().MessageId; | |
var message = await emailApi.FetchEmailModelAsync(new 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
EmailThread thread = threads.Value.First(); | |
ListResponseOfEmailDto threadMessages = await emailApi.FetchEmailThreadMessagesAsync( | |
new FetchEmailThreadMessagesRequest( | |
thread.Id, "email.account", null, "INBOX", storage, storageFolder)); |
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-dotnet | |
// Initialization of properties of GetMapiPropertiesRequest | |
string documentFileName = "documentFileName"; | |
string pathToFolderInStorage = "path/to/folder/in/storage"; | |
string storageName = "storageName"; | |
GetMapiPropertiesRequest request = new GetMapiPropertiesRequest(documentFileName, pathToFolderInStorage, storageName); | |
// Get document properties | |
var properties = emailApi.GetMapiProperties(request); |
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
CalendarDtoList calendarDtoList = await emailApi.GetCalendarModelListAsync( | |
new 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
var threads = await emailApi.ListEmailThreadsAsync(new ListEmailThreadsRequest( | |
"INBOX", "email.account", null, 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
ContactDtoList contactDtoList = await emailApi.GetContactModelListAsync(new 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-dotnet | |
var alternate = await emailApi.ConvertCalendarModelToAlternateAsync( | |
new ConvertCalendarModelToAlternateRequest( | |
new CalendarDtoAlternateRq(calendar, "Create", null))); | |
email.AlternateViews.Add(alternate); |
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-dotnet | |
string pathToFolderInStorage = "path/to/folder/in/storage"; | |
string storageName = "storageName"; | |
string documentName = "newDocumentName"; | |
HierarchicalObjectRequest ojectRequest = new HierarchicalObjectRequest | |
{ | |
// Init MAPI file | |
HierarchicalObject = new HierarchicalObject | |
{ | |
Name = "IPM.Contact", | |
Type = "HierarchicalObject", | |
InternalProperties = new List<BaseObject> | |
{ | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagMessageClass':0x1A:String", | |
Type = null, | |
Value = "IPM.Contact" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagSubject':0x37:String", | |
Type = null, | |
Value = null | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagSubjectPrefix':0x3D:String", | |
Type = null, | |
Value = null | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagMessageFlags':0xE07:Integer32", | |
Type = null, | |
Value = "8" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagNormalizedSubject':0xE1D:String", | |
Type = null, | |
Value = null | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagBody':0x1000:String", | |
Type = null, | |
Value = null | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagStoreSupportMask':0x340D:Integer32", | |
Type = null, | |
Value = "265849" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagSurname':0x3A11:String", | |
Type = null, | |
Value = "Surname" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'PidTagOtherTelephoneNumber':0x3A1F:String", | |
Type = null, | |
Value = "+79123456789" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'':0x6662:Integer32", | |
Type = null, | |
Value = "0" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Tag:'':0x8002:Integer32", | |
Type = null, | |
Value = "1" | |
}, | |
new PrimitiveObject | |
{ | |
Name = "Lid:'PidLidAddressBookProviderArrayType':0x8029:Integer32:00062004-0000-0000-c000-000000000046", | |
Type = null, | |
Value = "1" | |
} | |
} | |
}, | |
// Init storage folder | |
StorageFolder = new StorageFolderLocation(storageName, pathToFolderInStorage) | |
}; | |
// Create MAPI request | |
CreateMapiRequest request = new CreateMapiRequest(); | |
request.name = documentName; | |
request.request = ojectRequest; | |
// Create MAPI file | |
emailApi.CreateMapi(request); |
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 emailApi.SetEmailReadFlagAsync(new SetEmailReadFlagRequest( | |
new SetMessageReadFlagAccountBaseRequest(imapAccount, null, | |
new 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 emailApi.SetEmailThreadReadFlagAsync(new SetEmailThreadReadFlagRequest(thread.Id, | |
new EmailThreadReadFlagRq("email.account", null, | |
new 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 emailApi.MoveEmailThreadAsync( | |
new MoveEmailThreadRequest(thread.Id, | |
new MoveEmailThreadRq("email.account", null, | |
new 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 bytes = File.ReadAllBytes("/tmp/alex.png"); | |
var imageBase64 = Convert.ToBase64String(bytes); | |
var result = await emailApi.AiBcrParseModelAsync(new AiBcrParseModelRequest( | |
new AiBcrBase64Rq(null, new List<AiBcrBase64Image> | |
{ | |
new AiBcrBase64Image(true, imageBase64) | |
}))); | |
ContactDto contact = result.Value.First(); |
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-dotnet | |
var bytes = File.ReadAllBytes(imageFilePath); | |
var imageBase64 = Convert.ToBase64String(bytes); | |
var result = await emailApi.AiBcrParseModelAsync( | |
new AiBcrParseModelRequest( | |
new AiBcrBase64Rq( | |
null, | |
new List<AiBcrBase64Image> | |
{ | |
new AiBcrBase64Image(true, imageBase64) | |
}))); | |
ContactDto firstVCard = result.Value.First(); | |
System.Console.WriteLine(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-dotnet | |
//Create email account object | |
var emailClientAccount = new EmailClientAccount | |
{ | |
Host = "smtp.gmail.com", | |
Port = 465, | |
ProtocolType = "SMTP", | |
SecurityOptions = "SSLAuto", | |
Credentials = new EmailClientAccountPasswordCredentials | |
{ | |
Login = "example@gmail.com", | |
Password = "password" | |
} | |
}; | |
var fileName = "fileName.account"; | |
//Save account | |
await emailApi.SaveEmailClientAccountAsync(new SaveEmailClientAccountRequest( | |
new StorageFileRqOfEmailClientAccount( | |
emailClientAccount, | |
new StorageFileLocation("First Storage", "folder/on/storage", fileName)))); | |
//Get email account from storage | |
var emailClientAccountFromStorage = await emailApi.GetEmailClientAccountAsync( | |
new GetEmailClientAccountRequest( | |
fileName, "folder/on/storage", "First 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-dotnet | |
// Create multi account object | |
var multiAccount = new EmailClientMultiAccount | |
{ | |
ReceiveAccounts = new List<EmailClientAccount> | |
{ | |
new EmailClientAccount | |
{ | |
Host = "imap.gmail.com", | |
Port = 993, | |
ProtocolType = "IMAP", | |
SecurityOptions = "SSLAuto", | |
Credentials = new EmailClientAccountOauthCredentials | |
{ | |
Login = "example@gmail.com", | |
ClientId = "client-id", | |
ClientSecret = "clientSecret", | |
RefreshToken = "refreshToken" | |
} | |
}, | |
new EmailClientAccount | |
{ | |
Host = "exchange.outlook.com", | |
Port = 443, | |
ProtocolType = "EWS", | |
SecurityOptions = "SSLAuto", | |
Credentials = new EmailClientAccountPasswordCredentials | |
{ | |
Login = "example@outlook.com", | |
Password = "password" | |
} | |
} | |
}, | |
SendAccount = new EmailClientAccount | |
{ | |
Host = "smtp.gmail.com", | |
Port = 465, | |
ProtocolType = "SMTP", | |
SecurityOptions = "SSLAuto", | |
Credentials = new EmailClientAccountOauthCredentials | |
{ | |
Login = "example@gmail.com", | |
ClientId = "client-id", | |
ClientSecret = "clientSecret", | |
RefreshToken = "refreshToken" | |
} | |
} | |
}; | |
var fileName = "fileName.multi.account"; | |
var storage = "First storage"; | |
var folder = "folder/on/storage"; | |
// Save multi account | |
await emailApi.SaveEmailClientMultiAccountAsync( | |
new SaveEmailClientMultiAccountRequest( | |
new StorageFileRqOfEmailClientMultiAccount( | |
multiAccount, | |
new StorageFileLocation(storage, folder, fileName)))); | |
// Get multi account object from storage | |
var multiAccountFromStorage = await emailApi.GetEmailClientMultiAccountAsync( | |
new 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-dotnet | |
var contactFile = $"{Guid.NewGuid().ToString()}.vcf"; | |
await emailApi.SaveContactModelAsync( | |
new SaveContactModelRequest( | |
"VCard", contactFile, | |
new StorageModelRqOfContactDto(contact, | |
new StorageFolderLocation(StorageName, 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 = await emailApi.ListEmailModelsAsync(new ListEmailModelsRequest( | |
imapFolderName, "('From' Contains '.com')", imapAccount, null, 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-dotnet | |
var messages = await emailApi.ListEmailModelsAsync(new ListEmailModelsRequest( | |
"INBOX", "('From' Contains '.com')", "email.multi.account", null, "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-dotnet | |
var email = new EmailDto | |
{ | |
From = new MailAddress("From address", "from@aspose.com", null), | |
To = new List<MailAddress> {new MailAddress("To address", "to@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
await emailApi.SendEmailModelAsync(new SendEmailModelRequest(new SendEmailModelRq( | |
"emailAccount.account", null, | |
new 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 EmailDto | |
{ | |
From = new MailAddress("From address", "example@gmail.com", null), | |
To = new List<MailAddress> {new MailAddress("To address", "to@aspose.com", null)}, | |
Subject = "Some subject", | |
Body = "Some body" | |
}; | |
await emailApi.SendEmailModelAsync(new SendEmailModelRequest( | |
new SendEmailModelRq(smtpAccount, null, | |
new 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 EmailClientAccountPasswordCredentials { | |
Login = "example@gmail.com", | |
Password = "password" | |
}; | |
var receiveAccountDto = new EmailClientAccount { | |
Host = "imap.gmail.com", | |
Port = 993, | |
ProtocolType = "IMAP", | |
SecurityOptions = "SSLAuto", | |
Credentials = credentials | |
}; | |
var imapAccount = "imap.account"; | |
var accountFolder = "folder/on/storage"; | |
var storageName = "First storage"; | |
// Save account | |
await emailApi.SaveEmailClientAccountAsync( | |
new SaveEmailClientAccountRequest( | |
new StorageFileRqOfEmailClientAccount( | |
receiveAccountDto, new 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
//Create email account object | |
var sendAccountDto = new EmailClientAccount | |
{ | |
Host = "smtp.gmail.com", | |
Port = 465, | |
ProtocolType = "SMTP", | |
SecurityOptions = "SSLAuto", | |
Credentials = credentials | |
}; | |
var smtpAccount = "smtp.account"; | |
//Save account | |
await emailApi.SaveEmailClientAccountAsync(new SaveEmailClientAccountRequest( | |
new StorageFileRqOfEmailClientAccount( | |
sendAccountDto, | |
new 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
var account = new EmailClientAccount | |
{ | |
Host = "pop.gmail.com", | |
Port = 995, | |
ProtocolType = "POP3", | |
SecurityOptions = "SSLAuto", | |
Credentials = new EmailClientAccountPasswordCredentials | |
{ | |
Login = "example@gmail.com", | |
Password = "password" | |
}, | |
CacheFile = new StorageFileLocation("First storage", "cache/location/on/storage", "account.cache") | |
}; | |
await emailApi.SaveEmailClientAccountAsync(new SaveEmailClientAccountRequest( | |
new StorageFileRqOfEmailClientAccount( | |
account, | |
new StorageFileLocation("First storage", "account/location/on/storage", | |
"email.account")))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment