Last active
March 1, 2021 13:37
-
-
Save aspose-com-gists/522d47278b8ca448dc1d7eb97193322c to your computer and use it in GitHub Desktop.
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
Gists of Aspose.Email 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
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
string description = "Test Description"; | |
Appointment app = new Appointment("location", "test appointment", description, DateTime.Today, | |
DateTime.Today.AddDays(1), "first@test.com", "second@test.com"); | |
IcsSaveOptions saveOptions = IcsSaveOptions.Default; | |
saveOptions.ProductId = "Test Corporation"; | |
app.Save(dataDir + "ChangeProdIdOfICS.ics", saveOptions); |
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/Aspose.Email-for-.NET | |
public static void Run() | |
{ | |
string dataDir = RunExamples.GetDataDir_Email(); | |
var fileName = dataDir + "LinksSample.eml"; | |
MailMessage msg = MailMessage.Load(fileName); | |
Console.WriteLine(msg.GetHtmlBodyText(RenderHyperlinkWithHref)); | |
Console.WriteLine(msg.GetHtmlBodyText(RenderHyperlinkWithoutHref)); | |
} | |
private static string RenderHyperlinkWithHref(string source) | |
{ | |
int start = source.IndexOf("href=\"") + "href=\"".Length; | |
int end = source.IndexOf("\"", start + "href=\"".Length); | |
string href = source.Substring(start, end - start); | |
start = source.IndexOf(">") + 1; | |
end = source.IndexOf("<", start); | |
string text = source.Substring(start, end - start); | |
string link = string.Format("{0}<{1}>", text, href); | |
return link; | |
} | |
private static string RenderHyperlinkWithoutHref(string source) | |
{ | |
int start = source.IndexOf(">") + 1; | |
int end = source.IndexOf("<", start); | |
string text = source.Substring(start, end - start); | |
return text; | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
MailMessage eml = MailMessage.Load(dataDir + "Attachments.eml"); | |
MhtSaveOptions opt = SaveOptions.DefaultMhtml; | |
eml.Save(dataDir + "CustomOrderOfInformationInMHTML_1.mhtml", opt); | |
opt.RenderingHeaders.Add(MhtTemplateName.From); | |
opt.RenderingHeaders.Add(MhtTemplateName.Subject); | |
opt.RenderingHeaders.Add(MhtTemplateName.To); | |
opt.RenderingHeaders.Add(MhtTemplateName.Sent); | |
eml.Save(dataDir + "CustomOrderOfInformationInMHTML_2.mhtml", opt); | |
opt.RenderingHeaders.Clear(); | |
opt.RenderingHeaders.Add(MhtTemplateName.Attachments); | |
opt.RenderingHeaders.Add(MhtTemplateName.Cc); | |
opt.RenderingHeaders.Add(MhtTemplateName.Subject); | |
eml.Save(dataDir + "CustomOrderOfInformationInMHTML_3.mhtml", opt); |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
MailMessage mail = MailMessage.Load(dataDir + "HtmlWithUrlSample.eml"); | |
string body_with_url = mail.GetHtmlBodyText(true);// body will contain URL | |
string body_without_url = mail.GetHtmlBodyText(false);// body will not contain URL | |
Console.WriteLine("Body with URL: " + body_with_url); | |
Console.WriteLine("Body without URL: " + body_without_url); |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
TgzReader reader = new TgzReader(dataDir + "ZimbraSample.tgz"); | |
while (reader.ReadNextMessage()) | |
{ | |
string directoryName = reader.CurrentDirectory; | |
Console.WriteLine(directoryName); | |
MailMessage eml = reader.CurrentMessage; | |
Console.WriteLine(eml.Subject); | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
using (NotesStorageFacility nsf = new NotesStorageFacility(dataDir + "SampleNSF.nsf")) | |
{ | |
foreach (MailMessage eml in nsf.EnumerateMessages()) | |
{ | |
Console.WriteLine(eml.Subject); | |
} | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
string outputDir = RunExamples.GetDataDir_Email() + "Zimbra/"; | |
using (TgzReader reader = new TgzReader(dataDir + "ZimbraSample.tgz")) | |
{ | |
reader.ExportTo(outputDir); | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Email(); | |
var fileName = dataDir + "test.eml"; | |
MailMessage msg = MailMessage.Load(fileName); | |
MemoryStream ms = new MemoryStream(); | |
EmlSaveOptions opt = new EmlSaveOptions(MailMessageSaveType.EmlFormat); | |
opt.CustomProgressHandler = new ConversionProgressEventHandler(ShowEmlConversionProgress); | |
msg.Save(ms, opt); |
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/Aspose.Email-for-.NET | |
private static void ShowEmlConversionProgress(ProgressEventHandlerInfo info) | |
{ | |
int total; | |
int saved; | |
switch (info.EventType) | |
{ | |
case ProgressEventType.MimeStructureCreated: | |
total = info.TotalMimePartCount; | |
saved = info.SavedMimePartCount; | |
Console.WriteLine("MimeStructureCreated - TotalMimePartCount: " + total); | |
Console.WriteLine("MimeStructureCreated - SavedMimePartCount: " + saved); | |
break; | |
case ProgressEventType.MimePartSaved: | |
total = info.TotalMimePartCount; | |
saved = info.SavedMimePartCount; | |
Console.WriteLine("MimePartSaved - TotalMimePartCount: " + total); | |
Console.WriteLine("MimePartSaved - SavedMimePartCount: " + saved); | |
break; | |
case ProgressEventType.SavedToStream: | |
total = info.TotalMimePartCount; | |
saved = info.SavedMimePartCount; | |
Console.WriteLine("SavedToStream - TotalMimePartCount: " + total); | |
Console.WriteLine("SavedToStream - SavedMimePartCount: " + saved); | |
break; | |
} | |
} |
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/Aspose.Email-for-.NET | |
string dataDir = RunExamples.GetDataDir_Output(); | |
AmpMessage msg = new AmpMessage(); | |
msg.HtmlBody = "<html><body> Hello AMP </body></html>"; | |
//add AmpAnim component | |
AmpAnim anim = new AmpAnim(800, 400); | |
anim.Src = "https://placekitten.com/800/400"; | |
anim.Alt = "Test alt"; | |
anim.Attribution = "The Go gopher was designed by Reneee French"; | |
anim.Attributes.Layout = LayoutType.Responsive; | |
anim.Fallback = "offline"; | |
msg.AddAmpComponent(anim); | |
//add AmpImage component | |
AmpImage img = new AmpImage(800, 400); | |
img.Src = "https://placekitten.com/800/400"; | |
img.Alt = "Test alt"; | |
img.Attributes.Layout = LayoutType.Responsive; | |
msg.AddAmpComponent(img); | |
//add AmpCarousel component | |
AmpCarousel car = new AmpCarousel(800, 400); | |
img = new AmpImage(800, 400); | |
img.Src = "https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_caleb_woods.jpg"; | |
img.Alt = "Test 2 alt"; | |
img.Attributes.Layout = LayoutType.Fixed; | |
car.Images.Add(img); | |
img = new AmpImage(800, 400); | |
img.Src = "https://placekitten.com/800/400"; | |
img.Alt = "Test alt"; | |
img.Attributes.Layout = LayoutType.Responsive; | |
car.Images.Add(img); | |
img = new AmpImage(800, 400); | |
img.Src = "https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_craig_mclaclan.jpg"; | |
img.Alt = "Test 3 alt"; | |
img.Attributes.Layout = LayoutType.Fill; | |
car.Images.Add(img); | |
msg.AddAmpComponent(car); | |
//add AmpFitText component | |
AmpFitText txt = new AmpFitText("Lorem ipsum dolor sit amet, has nisl nihil convenire et, vim at aeque inermis reprehendunt."); | |
txt.Attributes.Width = 600; | |
txt.Attributes.Height = 300; | |
txt.Attributes.Layout = LayoutType.Responsive; | |
txt.MinFontSize = 8; | |
txt.MaxFontSize = 16; | |
txt.Value = "Lorem ipsum dolor sit amet, has nisl nihil convenire et, vim at aeque inermis reprehendunt."; | |
msg.AddAmpComponent(txt); | |
//add AmpAccordion component | |
AmpAccordion acc = new AmpAccordion(); | |
acc.ExpandSingleSection = true; | |
Section sec = new Section(); | |
sec.Header = new SectionHeader(SectionHeaderType.h2, "Section 1"); | |
sec.Value = new SectionValue("Content in section 1."); | |
acc.Sections.Add(sec); | |
sec = new Section(); | |
sec.Header = new SectionHeader(SectionHeaderType.h2, "Section 2"); | |
sec.Value = new SectionValue("Content in section 2."); | |
acc.Sections.Add(sec); | |
img = new AmpImage(800, 400); | |
img.Src = "https://placekitten.com/800/400"; | |
img.Alt = "Test alt"; | |
img.Attributes.Layout = LayoutType.Responsive; | |
sec = new Section(); | |
sec.Header = new SectionHeader(SectionHeaderType.h2, "Section 3"); | |
sec.Value = new SectionValue(img); | |
acc.Sections.Add(sec); | |
msg.AddAmpComponent(acc); | |
//add AmpForm component | |
AmpForm form = new AmpForm(); | |
form.Method = FormMethod.Post; | |
form.ActionXhr = "https://example.com/subscribe"; | |
form.Target = FormTarget.Top; | |
FormField field = new FormField("Name:", "text"); | |
field.Name = "name"; | |
field.IsRequired = true; | |
form.Fieldset.Add(field); | |
field = new FormField("Email:", "email"); | |
field.Name = "email"; | |
field.IsRequired = true; | |
form.Fieldset.Add(field); | |
field = new FormField(); | |
field.InputType = "submit"; | |
field.Value = "Subscribe"; | |
form.Fieldset.Add(field); | |
msg.AddAmpComponent(form); | |
msg.Save(dataDir + "AmpTest_1.eml"); | |
MailMessage savedmsg = MailMessage.Load(dataDir + "AmpTest_1.eml"); | |
AmpMessage ampMsg = savedmsg as AmpMessage; | |
if (ampMsg != null) | |
{ | |
DateTime dt = new DateTime(2019, 9, 27, 1, 1, 1, DateTimeKind.Utc); | |
AmpTimeago time = new AmpTimeago(dt); | |
time.Attributes.Width = 600; | |
time.Attributes.Height = 300; | |
time.Attributes.Layout = LayoutType.Fixed; | |
time.Locale = "en"; | |
time.Cutoff = 600; | |
ampMsg.AddAmpComponent(time); | |
ampMsg.Save(dataDir + "AmpTest_2.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
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
const string mailboxUri = "<HOST>"; | |
const string domain = @""; | |
const string username = @"<USERNAME>"; | |
const string password = @"<PASSWORD>"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri); | |
foreach (ExchangeMessageInfo msgInfo in msgCollection) | |
{ | |
Console.WriteLine("Subject:" + msgInfo.Subject); | |
client.ArchiveItem(client.MailboxInfo.InboxUri, msgInfo.UniqueUri); | |
} | |
client.Dispose(); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
PageSettings pageSettings = new PageSettings { AscendingSorting = false }; | |
ImapPageInfo pageInfo = imapClient.ListMessagesByPage(5, pageSettings); | |
ImapMessageInfoCollection messages = pageInfo.Items; | |
foreach (ImapMessageInfo message in messages) | |
{ | |
Console.WriteLine(message.Subject + " -> " + message.Date.ToString()); | |
} |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
ImapMessageInfoCollection messageInfoCol = imapClient.ListMessages(); | |
foreach (ImapMessageInfo imapMessageInfo in messageInfoCol) | |
{ | |
Console.WriteLine("ListUnsubscribe Header: " + imapMessageInfo.ListUnsubscribe); | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_IMAP(); | |
// Create an instance of the ImapClient class | |
ImapClient imapClient = new ImapClient(); | |
// Specify host, username and password, and set port for your client | |
imapClient.Host = "imap.gmail.com"; | |
imapClient.Username = "your.username@gmail.com"; | |
imapClient.Password = "your.password"; | |
imapClient.Port = 993; | |
imapClient.SecurityOptions = SecurityOptions.Auto; | |
ImapMailboxInfo mailboxInfo = imapClient.MailboxInfo; | |
ImapFolderInfo info = imapClient.GetFolderInfo(mailboxInfo.Inbox.Name); | |
ImapFolderInfoCollection infos = new ImapFolderInfoCollection(); | |
infos.Add(info); | |
imapClient.Backup(infos, dataDir + @"\ImapBackup.pst", BackupOptions.Recursive); |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_IMAP(); | |
// Create an instance of the ImapClient class | |
ImapClient imapClient = new ImapClient(); | |
// Specify host, username and password, and set port for your client | |
imapClient.Host = "imap.gmail.com"; | |
imapClient.Username = "your.username@gmail.com"; | |
imapClient.Password = "your.password"; | |
imapClient.Port = 993; | |
imapClient.SecurityOptions = SecurityOptions.Auto; | |
imapClient.UseMultiConnection = MultiConnectionMode.Enable; | |
ImapMailboxInfo mailboxInfo = imapClient.MailboxInfo; | |
ImapFolderInfo info = imapClient.GetFolderInfo(mailboxInfo.Inbox.Name); | |
ImapFolderInfoCollection infos = new ImapFolderInfoCollection(); | |
infos.Add(info); | |
imapClient.Backup(infos, dataDir + @"\ImapBackup.pst", BackupOptions.Recursive); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
ImapMessageInfoCollection messageInfoCol = imapClient.ListMessages(); | |
Console.WriteLine("ListMessages Count: " + messageInfoCol.Count); | |
int[] sequenceNumberAr = messageInfoCol.Select((ImapMessageInfo mi) => mi.SequenceNumber).ToArray(); | |
string[] uniqueIdAr = messageInfoCol.Select((ImapMessageInfo mi) => mi.UniqueId).ToArray(); | |
IList<MailMessage> fetchedMessagesBySNumMC = imapClient.FetchMessages(sequenceNumberAr); | |
Console.WriteLine("FetchMessages-sequenceNumberAr Count: " + fetchedMessagesBySNumMC.Count); | |
IList<MailMessage> fetchedMessagesByUidMC = imapClient.FetchMessages(uniqueIdAr); | |
Console.WriteLine("FetchMessages-uniqueIdAr Count: " + fetchedMessagesByUidMC.Count); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
List<MailMessage> messages = new List<MailMessage>(); | |
for (int i = 0; i < 20; i++) | |
{ | |
MailMessage message = new MailMessage( | |
"<EMAIL ADDRESS>", | |
"<EMAIL ADDRESS>", | |
"Test Message - " + Guid.NewGuid().ToString(), | |
"IMAP Group Append with MultiConnection"); | |
messages.Add(message); | |
} | |
imapClient.ConnectionsQuantity = 5; | |
imapClient.UseMultiConnection = MultiConnectionMode.Enable; | |
imapClient.AppendMessages(messages); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
imapClient.SelectFolder("Inbox"); | |
imapClient.ConnectionsQuantity = 5; | |
imapClient.UseMultiConnection = MultiConnectionMode.Enable; | |
DateTime multiConnectionModeStartTime = DateTime.Now; | |
ImapMessageInfoCollection messageInfoCol1 = imapClient.ListMessages(true); | |
TimeSpan multiConnectionModeTimeSpan = DateTime.Now - multiConnectionModeStartTime; | |
imapClient.UseMultiConnection = MultiConnectionMode.Disable; | |
DateTime singleConnectionModeStartTime = DateTime.Now; | |
ImapMessageInfoCollection messageInfoCol2 = imapClient.ListMessages(true); | |
TimeSpan singleConnectionModeTimeSpan = DateTime.Now - singleConnectionModeStartTime; | |
double performanceRelation = singleConnectionModeTimeSpan.TotalMilliseconds / multiConnectionModeTimeSpan.TotalMilliseconds; | |
Console.WriteLine("Performance Relation: " + performanceRelation); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
ImapQueryBuilder imapQueryBuilder = new ImapQueryBuilder(); | |
imapQueryBuilder.HasNoFlags(ImapMessageFlags.IsRead); /* get unread messages. */ | |
MailQuery query = imapQueryBuilder.GetQuery(); | |
imapClient.ReadOnly = true; | |
imapClient.SelectFolder("Inbox"); | |
ImapMessageInfoCollection messageInfoCol = imapClient.ListMessages(query); | |
Console.WriteLine("Initial Unread Count: " + messageInfoCol.Count()); | |
if (messageInfoCol.Count() > 0) | |
{ | |
imapClient.FetchMessage(messageInfoCol[0].SequenceNumber); | |
messageInfoCol = imapClient.ListMessages(query); | |
// This count will be equal to the initial count | |
Console.WriteLine("Updated Unread Count: " + messageInfoCol.Count()); | |
} | |
else | |
{ | |
Console.WriteLine("No unread messages found"); | |
} |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_IMAP(); | |
// Create an instance of the ImapClient class | |
ImapClient imapClient = new ImapClient(); | |
// Specify host, username and password, and set port for your client | |
imapClient.Host = "imap.gmail.com"; | |
imapClient.Username = "your.username@gmail.com"; | |
imapClient.Password = "your.password"; | |
imapClient.Port = 993; | |
imapClient.SecurityOptions = SecurityOptions.Auto; | |
RestoreSettings settings = new RestoreSettings(); | |
settings.Recursive = true; | |
PersonalStorage pst = PersonalStorage.FromFile(dataDir + @"\ImapBackup.pst"); | |
imapClient.Restore(pst, settings); |
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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_IMAP(); | |
// Create an instance of the ImapClient class | |
ImapClient imapClient = new ImapClient(); | |
// Specify host, username and password, and set port for your client | |
imapClient.Host = "imap.gmail.com"; | |
imapClient.Username = "your.username@gmail.com"; | |
imapClient.Password = "your.password"; | |
imapClient.Port = 993; | |
imapClient.SecurityOptions = SecurityOptions.Auto; | |
imapClient.UseMultiConnection = MultiConnectionMode.Enable; | |
RestoreSettings settings = new RestoreSettings(); | |
settings.Recursive = true; | |
PersonalStorage pst = PersonalStorage.FromFile(dataDir + @"\Outlook.pst"); | |
imapClient.Restore(pst, settings); |
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/Aspose.Email-for-.NET | |
ImapClient imapClient = new ImapClient(); | |
imapClient.Host = "<HOST>"; | |
imapClient.Port = 993; | |
imapClient.Username = "<USERNAME>"; | |
imapClient.Password = "<PASSWORD>"; | |
imapClient.SupportedEncryption = EncryptionProtocols.Tls; | |
imapClient.SecurityOptions = SecurityOptions.SSLImplicit; | |
ImapMailboxInfo mailboxInfo = imapClient.MailboxInfo; | |
Console.WriteLine(mailboxInfo.Inbox); | |
Console.WriteLine(mailboxInfo.DraftMessages); | |
Console.WriteLine(mailboxInfo.JunkMessages); | |
Console.WriteLine(mailboxInfo.SentMessages); | |
Console.WriteLine(mailboxInfo.Trash); |
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/Aspose.Email-for-.NET | |
// Outlook directory | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
MailMessage mailMessage = MailMessage.Load(dataDir + "TestAppointment.eml"); | |
MapiConversionOptions conversionOptions = new MapiConversionOptions(); | |
conversionOptions.Format = OutlookMessageFormat.Unicode; | |
// default value for ForcedRtfBodyForAppointment is true | |
conversionOptions.ForcedRtfBodyForAppointment = false; | |
MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage, conversionOptions); | |
Console.WriteLine("Body Type: " + mapiMessage.BodyType); | |
mapiMessage.Save(dataDir + "TestAppointment_out.msg"); |
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/Aspose.Email-for-.NET | |
// Outlook directory | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
MapiContact contact = new MapiContact(); | |
contact.NameInfo = new MapiContactNamePropertySet("Jane", "A.", "Buell"); | |
contact.ProfessionalInfo = new MapiContactProfessionalPropertySet("Aspose Pty Ltd", "Social work assistant"); | |
contact.PersonalInfo.PersonalHomePage = "Aspose.com"; | |
contact.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("test@test.com"); | |
contact.Telephones.HomeTelephoneNumber = "06605040000"; | |
VCardSaveOptions opt = new VCardSaveOptions(); | |
opt.Version = VCardVersion.V30; | |
contact.Save(dataDir + "V30.vcf", opt); |
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/Aspose.Email-for-.NET | |
public static void Run() | |
{ | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
OlmStorage storage = new OlmStorage(dataDir + "SampleOLM.olm"); | |
PrintMessageCount(storage.FolderHierarchy); | |
} | |
public static void PrintMessageCount(List<OlmFolder> folders) | |
{ | |
foreach (OlmFolder folder in folders) | |
{ | |
Console.WriteLine("Message Count [" + folder.Name + "]: " + folder.MessageCount); | |
} | |
} |
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/Aspose.Email-for-.NET | |
public static void Run() | |
{ | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
OlmStorage storage = new OlmStorage(dataDir + "SampleOLM.olm"); | |
PrintPath(storage, storage.FolderHierarchy); | |
} | |
public static void PrintPath(OlmStorage storage, List<OlmFolder> folders) | |
{ | |
foreach (OlmFolder folder in folders) | |
{ | |
// print the current folder path | |
Console.WriteLine(folder.Path); | |
if (folder.SubFolders.Count > 0) | |
{ | |
PrintPath(storage, folder.SubFolders); | |
} | |
} | |
} |
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/Aspose.Email-for-.NET | |
using (PersonalStorage pst = PersonalStorage.FromFile(dataDir + "Outlook.pst")) | |
{ | |
PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder(); | |
queryBuilder.OnlyFoldersCreatedByUser.Equals(true); | |
FolderInfoCollection subfolders = pst.RootFolder.GetSubFolders(queryBuilder.GetQuery()); | |
foreach (FolderInfo folder in subfolders) | |
{ | |
Console.WriteLine(folder.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/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
using (PersonalStorage pst = PersonalStorage.FromFile(dataDir + "passwordprotectedPST.pst")) | |
{ | |
Console.WriteLine("The storage is password protected - " + pst.Store.IsPasswordProtected); | |
Console.WriteLine("Password is valid - " + pst.Store.IsPasswordValid("Password1")); | |
} |
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/Aspose.Email-for-.NET | |
// Create an instance of the Pop3Client class | |
Pop3Client pop3Client = new Pop3Client(); | |
pop3Client.Host = "<HOST>"; | |
pop3Client.Port = 995; | |
pop3Client.Username = "<USERNAME>"; | |
pop3Client.Password = "<PASSWORD>"; | |
Pop3MessageInfoCollection messageInfoCol = pop3Client.ListMessages(); | |
Console.WriteLine("ListMessages Count: " + messageInfoCol.Count); | |
int[] sequenceNumberAr = messageInfoCol.Select((Pop3MessageInfo mi) => mi.SequenceNumber).ToArray(); | |
string[] uniqueIdAr = messageInfoCol.Select((Pop3MessageInfo mi) => mi.UniqueId).ToArray(); | |
IList<MailMessage> fetchedMessagesBySNumMC = pop3Client.FetchMessages(sequenceNumberAr); | |
Console.WriteLine("FetchMessages-sequenceNumberAr Count: " + fetchedMessagesBySNumMC.Count); | |
IList<MailMessage> fetchedMessagesByUidMC = pop3Client.FetchMessages(uniqueIdAr); | |
Console.WriteLine("FetchMessages-uniqueIdAr Count: " + fetchedMessagesByUidMC.Count); |
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/Aspose.Email-for-.NET | |
// Create an instance of the Pop3Client class | |
Pop3Client pop3Client = new Pop3Client(); | |
pop3Client.Host = "<HOST>"; | |
pop3Client.Port = 995; | |
pop3Client.Username = "<USERNAME>"; | |
pop3Client.Password = "<PASSWORD>"; | |
pop3Client.ConnectionsQuantity = 5; | |
pop3Client.UseMultiConnection = MultiConnectionMode.Enable; | |
DateTime multiConnectionModeStartTime = DateTime.Now; | |
Pop3MessageInfoCollection messageInfoCol1 = pop3Client.ListMessages(); | |
TimeSpan multiConnectionModeTimeSpan = DateTime.Now - multiConnectionModeStartTime; | |
pop3Client.UseMultiConnection = MultiConnectionMode.Disable; | |
DateTime singleConnectionModeStartTime = DateTime.Now; | |
Pop3MessageInfoCollection messageInfoCol2 = pop3Client.ListMessages(); | |
TimeSpan singleConnectionModeTimeSpan = DateTime.Now - singleConnectionModeStartTime; | |
Console.WriteLine("multyConnectionModeTimeSpan: " + multiConnectionModeTimeSpan.TotalMilliseconds); | |
Console.WriteLine("singleConnectionModeTimeSpan: " + singleConnectionModeTimeSpan.TotalMilliseconds); | |
double performanceRelation = singleConnectionModeTimeSpan.TotalMilliseconds / multiConnectionModeTimeSpan.TotalMilliseconds; | |
Console.WriteLine("Performance Relation: " + performanceRelation); |
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/Aspose.Email-for-.NET | |
SmtpClient smtpClient = new SmtpClient(); | |
smtpClient.Host = "<HOST>"; | |
smtpClient.Username = "<USERNAME>"; | |
smtpClient.Password = "<PASSWORD>"; | |
smtpClient.Port = 587; | |
smtpClient.SupportedEncryption = EncryptionProtocols.Tls; | |
smtpClient.SecurityOptions = SecurityOptions.SSLExplicit; | |
List<MailMessage> messages = new List<MailMessage>(); | |
for (int i = 0; i < 20; i++) | |
{ | |
MailMessage message = new MailMessage( | |
"<EMAIL ADDRESS>", | |
"<EMAIL ADDRESS>", | |
"Test Message - " + Guid.NewGuid().ToString(), | |
"SMTP Send Messages with MultiConnection"); | |
messages.Add(message); | |
} | |
smtpClient.ConnectionsQuantity = 5; | |
smtpClient.UseMultiConnection = MultiConnectionMode.Enable; | |
smtpClient.Send(messages); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment