Knowledgebase (2311)
Children categories
Spire.Email allows developers to search mailbox for email messages that match the given search criteria. This article illustrates how to search email messages using Spire.Email component.
Detail steps:
Step 1: Create an ImapClient instance.
ImapClient imap = new ImapClient();
Step 2: Set host, port, authentication and connection protocol.
imap.Host = "outlook.office365.com"; imap.Port = 143; imap.Username = "LeonDavisLD@outlook.com"; imap.Password = "password"; imap.ConnectionProtocols = ConnectionProtocols.Ssl;
Step 3: connect the imap server.
imap.Connect();
Step 4: Select Inbox folder.
imap.Select("Inbox");
Step 5: Search email messages in the folder that match the search criteria.
//Search email messages sent from “Alice”
ImapMessageCollection messages = imap.Search("'From' Contains 'Alice'");
Console.WriteLine("Number of messages sent from Alice: " + messages.Count);
//Search email messages with “Spire” string in subject
messages = imap.Search("'Subject' Contains 'Spire'");
Console.WriteLine("Number of messages with 'Spire' in subject: " + messages.Count);
Screenshot:

Full code:
using Spire.Email;
using Spire.Email.IMap;
using System;
namespace SearchEmailMessages
{
class Program
{
static void Main(string[] args)
{
//Create an ImapClient instance
ImapClient imap = new ImapClient();
//Set host, port, authentication and connection protocol
imap.Host = "outlook.office365.com";
imap.Port = 143;
imap.Username = "LeonDavisLD@outlook.com";
imap.Password = "password";
imap.ConnectionProtocols = ConnectionProtocols.Ssl;
//Connect the imap server
imap.Connect();
//Select Inbox folder
imap.Select("Inbox");
//Search email messages sent from "Alice"
ImapMessageCollection messages = imap.Search("'From' Contains 'Alice'");
Console.WriteLine("Number of messages sent from Alice: " + messages.Count);
//Search email messages with “Spire” string in subject
messages = imap.Search("'Subject' Contains 'Spire'");
Console.WriteLine("Number of messages with 'Spire' in subject: " + messages.Count);
}
}
}
Imports Spire.Email
Imports Spire.Email.IMap
Namespace SearchEmailMessages
Class Program
Private Shared Sub Main(args As String())
'Create an ImapClient instance
Dim imap As New ImapClient()
'Set host, port, authentication and connection protocol
imap.Host = "outlook.office365.com"
imap.Port = 143
imap.Username = "LeonDavisLD@outlook.com"
imap.Password = "password"
imap.ConnectionProtocols = ConnectionProtocols.Ssl
'Connect the imap server
imap.Connect()
'Select Inbox folder
imap.[Select]("Inbox")
'Search email messages sent from "Alice"
Dim messages As ImapMessageCollection = imap.Search("'From' Contains 'Alice'")
Console.WriteLine("Number of messages sent from Alice: " + messages.Count)
'Search email messages with “Spire” string in subject
messages = imap.Search("'Subject' Contains 'Spire'")
Console.WriteLine("Number of messages with 'Spire' in subject: " + messages.Count)
End Sub
End Class
End Namespace
This article demonstrates how to delete a specific email message along with all email messages using Spire.Email component.
Detail steps:
Step 1: Create a POP3 client.
Pop3Client pop3 = new Pop3Client();
Step 2: Set host, authentication, port and connection protocol.
pop3.Host = "outlook.office365.com"; pop3.Username = "LeonDavisLD@outlook.com"; pop3.Password = "password"; pop3.Port = 995; pop3.EnableSsl = true;
Step 3: Connect the pop server.
pop3.Connect();
Step 4: Get the number of messages before deleting message(s).
//Get the number of messages before deleting message(s)
Pop3MessageInfoCollection messages = pop3.GetAllMessages();
Console.WriteLine("Number of messages before deleting: " + messages.Count);
Step 5: Delete message(s).
//Delete an email message by its sequence number pop3.DeleteMessage(2); //Delete all messages //pop3.DeleteAllMessages();
Step 6: Get the number of messages after deleting message(s).
//Get the number of messages after deleting message(s)
messages = pop3.GetAllMessages();
Console.WriteLine("Number of messages after deleting: " + messages.Count);

Full code:
using Spire.Email;
using Spire.Email.Pop3;
using System;
namespace DeleteEmailMessages
{
class Program
{
static void Main(string[] args)
{
//Create a POP3 client
Pop3Client pop3 = new Pop3Client();
//Set host, authentication, port and connection protocol
pop3.Host = "outlook.office365.com";
pop3.Username = "LeonDavisLD@outlook.com";
pop3.Password = "password";
pop3.Port = 995;
pop3.EnableSsl = true;
//Connect the pop server
pop3.Connect();
//Get the number of messages before deleting message(s)
Pop3MessageInfoCollection messages = pop3.GetAllMessages();
Console.WriteLine("Number of messages before deleting: " + messages.Count);
//Delete an email message by its sequence number
pop3.DeleteMessage(2);
//Delete all messages
//pop3.DeleteAllMessages();
//Get the number of messages after deleting message(s)
messages = pop3.GetAllMessages();
Console.WriteLine("Number of messages after deleting: " + messages.Count);
}
}
}
Imports Spire.Email
Imports Spire.Email.Pop3
Namespace DeleteEmailMessages
Class Program
Private Shared Sub Main(args As String())
'Create a POP3 client
Dim pop3 As New Pop3Client()
'Set host, authentication, port and connection protocol
pop3.Host = "outlook.office365.com"
pop3.Username = "LeonDavisLD@outlook.com"
pop3.Password = "password"
pop3.Port = 995
pop3.EnableSsl = True
'Connect the pop server
pop3.Connect()
'Get the number of messages before deleting message(s)
Dim messages As Pop3MessageInfoCollection = pop3.GetAllMessages()
Console.WriteLine("Number of messages before deleting: " + messages.Count)
'Delete an email message by its sequence number
pop3.DeleteMessage(2)
'Delete all messages
'pop3.DeleteAllMessages();
'Get the number of messages after deleting message(s)
messages = pop3.GetAllMessages()
Console.WriteLine("Number of messages after deleting: " + messages.Count)
End Sub
End Class
End Namespace
WordArt is a feature in MS Word that allows you to insert colorful and stylish text into your document. Apart from that, it can also bend, stretch, or skew the shape of the text, which is a quick way to make the text stand out with special effects. In this article, you will learn how to programmatically insert WordArt in a Word document using Spire.Doc for .NET.
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Insert WordArt in Word
The ShapeType enumeration provided by Spire.Doc for .NET defines a variety of WordArt shape types whose names begin with "Text". In order to create a WordArt in Word, you need to initialize an instance of ShapeObject and specify the WordArt type and text content. The detailed steps are as follows:
- Create a Document instance.
- Add a section to the document using Document.AddSection() method, and then add a paragraph to the section using Section.AddParagraph() method.
- Append a shape to the paragraph and specify the shape size and type using Paragraph.AppendShape(float width, float height, ShapeType shapeType) method.
- Set the position of the shape using ShapeObject.VerticalPosition and ShapeObject.HorizontalPosition properties.
- Set the text of WordArt using WordArt.Text property.
- Set the fill color and stroke color of WordArt using ShapeObject.FillColor and ShapeObject.StrokeColor properties.
- Save the document to another file using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
namespace CreatWordArt
{
class Program
{
static void Main(string[] args)
{
//Create a Document instance
Document doc = new Document();
//Add a section
Section section = doc.AddSection();
//Add a paragraph
Paragraph paragraph = section.AddParagraph();
//Append a shape to the paragraph and specify the shape size and type
ShapeObject shape = paragraph.AppendShape(400, 150, ShapeType.TextDeflateBottom);
//Set the position of the shape
shape.VerticalPosition = 60;
shape.HorizontalPosition = 60;
//Set the text of WordArt
shape.WordArt.Text = "Create WordArt in Word";
//Set the fill color and stroke color of WordArt
shape.FillColor = System.Drawing.Color.Cyan;
shape.StrokeColor = System.Drawing.Color.DarkBlue;
//Save the document
doc.SaveToFile("CreateWordArt.docx", FileFormat.Docx2013);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.