This article demonstrates how to set the row height and column width of an existing table in PowerPoint document using Spire.Presentation in C# and VB.NET.

The following screenshot shows the table before setting row height and column width.

Set Table Row Height and Column Width in PowerPoint

Detail steps:

Step 1: Instantiate a Presentation object and load the PowerPoint document.

Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");

Step 2: Get the first slide.

ISlide slide = ppt.Slides[0];

Step 3: Get the first table on the slide.

ITable table = ppt.Slides[0].Shapes[0] as ITable;

Step 4: Set table row height and column width.

table.TableRows[1].Height = 50;
table.ColumnsList[1].Width = 100;

Step 5: Save the document.

ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

Screenshot:

Set Table Row Height and Column Width in PowerPoint

Full code:

[C#]
using Spire.Presentation;

namespace Set_table_column_width_and_row_height
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Input.pptx");

            ISlide slide = ppt.Slides[0];            

            ITable table = ppt.Slides[0].Shapes[0] as ITable;

            table.TableRows[1].Height = 50;
            table.ColumnsList[1].Width = 100;

            ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
        }
    }
}
[VB.NET]
Imports Spire.Presentation

Namespace Set_table_column_width_and_row_height
	Class Program
		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation()
			ppt.LoadFromFile("Input.pptx")

			Dim slide As ISlide = ppt.Slides(0)

			Dim table As ITable = TryCast(ppt.Slides(0).Shapes(0), ITable)

			table.TableRows(1).Height = 50
			table.ColumnsList(1).Width = 100

			ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013)
		End Sub
	End Class
End Namespace

A file with the EMLX or EML file extension is a Mail Message file used to store an email message. EML/EMLX file can converted to MHTML or MSG file format with few lines of core code by using Spire.Email.

Convert EML/EMLX to MHTML

[C#]
MailMessage message = MailMessage.Load("example.eml");
message.Save("ToMhtml.mhtml", MailMessageFormat.Mhtml);
Console.WriteLine("Done");
[VB.NET]
Dim message As MailMessage = MailMessage.Load("example.eml")
message.Save("ToMhtml.mhtml", MailMessageFormat.Mhtml)
Console.WriteLine("Done")

Convert EML/EMLX to MSG

[C#]
MailMessage message = MailMessage.Load("example.eml");
message.Save("ToMsg.msg", MailMessageFormat.Msg);
Console.WriteLine("Done");
[VB.NET]
Dim message As MailMessage = MailMessage.Load("example.eml")
message.Save("ToMsg.msg", MailMessageFormat.Msg)
Console.WriteLine("Done")

We have already demonstrated how to use Spire.Doc to add shapes to word document from code. Spire.Doc also supports to remove a single shape by index or clear all the shapes from the word document. This article will illustrates how to remove the shape from word document in C# and VB.NET.

Sample word document with shapes:

How to remove shape from word document in C# and VB.NET

Step 1: Initialize a new instance of Document class and load the document from file.

Document doc = new Document();
doc.LoadFromFile("Shapes.docx",FileFormat.Docx2010);

Step 2: Get the first section from the document and the first paragraph from the section.

Section section = doc.Sections[0];
Paragraph para = section.Paragraphs[0];

Step 3: Get shapes from the first paragraph.

ShapeObject shape = para.ChildObjects[0] as ShapeObject;

Step 4: Remove the shape or all the shapes.

//remove the third shape.
para.ChildObjects.RemoveAt(2);

////clear all the shapes.
//para.ChildObjects.Clear();

Step 5: Save the document to file.

doc.SaveToFile("Removeshape.docx",FileFormat.Docx2010);

Effective screenshot after removing one shape from the word document:

How to remove shape from word document in C# and VB.NET

Full codes:

[C#]
Document doc = new Document();
doc.LoadFromFile("Shapes.docx",FileFormat.Docx2010);

Section section = doc.Sections[0];

Paragraph para = section.Paragraphs[0];
ShapeObject shape = para.ChildObjects[0] as ShapeObject;

//remove the third shape.
para.ChildObjects.RemoveAt(2);

////clear all the shapes.
//para.ChildObjects.Clear();

doc.SaveToFile("Removeshape.docx",FileFormat.Docx2010);
[VB.NET]
Dim doc As New Document()
doc.LoadFromFile("Shapes.docx", FileFormat.Docx2010)
Dim section As Section = doc.Sections(0)
Dim para As Paragraph = section.Paragraphs(0)
Dim shape As ShapeObject = TryCast(para.ChildObjects(0), ShapeObject)
'remove the third shape.
para.ChildObjects.RemoveAt(2)
'''/clear all the shapes.
'para.ChildObjects.Clear();

doc.SaveToFile("Removeshape.docx", FileFormat.Docx2010)

Spire.Email supports to manage folder subscriptions by using ImapClient.Subscribe and ImapClient.Unsubscribe method.

The following example shows how to subscribe to a folder and unsubscribe from a folder 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: Subscribe folder using its name.

imap.Subscribe("Folder1");

Step 5: Unsubscribe folder.

imap.Unsubscribe("Folder2");

Screenshot:

Subscribe and Unsubscribe Folders in C#, VB.NET

Full code:

[C#]
//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();

//subscribe folder using its name
imap.Subscribe("Folder1");

//Unsubscribe folder
imap.Unsubscribe("Folder2");
[VB.NET]
'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()

'subscribe folder using its name
imap.Subscribe("Folder1")

'Unsubscribe folder
imap.Unsubscribe("Folder2")

Spire.Presentation supports to insert HTML formatted text to PowerPoint slide. The following code snippets demonstrate how to.

Step 1: Create an instance of Presentation class.

Presentation ppt = new Presentation();

Step 2: Insert an autoshape (rectangle) in slide.

IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 100));

Step 3: Clear default paragraphs in the shape.

shape.TextFrame.Paragraphs.Clear();

Step 4: Add paragraphs to shape from HTML code. Make sure your HTML segments are written between <html><body> and </body></html> tags, otherwise, AddFromHtml method will fail to work.

string htmlText= "<html><body><p>First paragraph</p><p>Second paragraph</p></body></html>";
shape.TextFrame.Paragraphs.AddFromHtml(htmlText);

Step 5: Save to file.

ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);

Output:

Append HTML String to PowerPoint in C#, VB.NET

Full Code:

[C#]
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 100));
shape.TextFrame.Paragraphs.Clear();

string htmlText= "<html><body><p>First paragraph</p><p>Second paragraph</p></body></html>";
shape.TextFrame.Paragraphs.AddFromHtml(htmlText);

ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);
[VB.NET]
Dim ppt As New Presentation()
Dim shape As IAutoShape = ppt.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 50, 400, 100))
shape.TextFrame.Paragraphs.Clear()

Dim htmlText As String = "<html><body><p>First paragraph</p><p>Second paragraph</p></body></html>";
shape.TextFrame.Paragraphs.AddFromHtml(htmlText)

ppt.SaveToFile("output.pptx", FileFormat.Pptx2013)

When we operate the email messages, we may need to send the message to many more email address. Spire.Email supports to send a message to many email addresses at one time. This article demonstrates how to add the new send To and Cc email address from an existing email message via Spire.Email in C# and VB.NET.

Firstly, please view the sample email message with one to and cc email address:

Update the send to email address for Email message

How to add new send to and cc email addresses:

[C#]
//Load the mail message from file
MailMessage mail = MailMessage.Load("Sample.msg");

//add a new To email address and its display name
mail.To.Add(new MailAddress("support@e-iceblue.com", "E-iceblue Support"));

// add a new Cc email address and its display name
mail.Cc.Add(new MailAddress("comments@e-iceblue.com", "Comments"));


// Save the message
mail.Save("ChangeEmailAddress.msg", MailMessageFormat.Msg);
[VB.NET]
Dim mail As MailMessage = MailMessage.Load("Sample.msg")

mail.[To].Add(New MailAddress("support@e-iceblue.com", "E-iceblue Support"))
mail.Cc.Add(New MailAddress("comments@e-iceblue.com", "Comments"))

mail.Save("ChangeEmailAddress.msg", MailMessageFormat.Msg)

Effective screenshot after changing the email address:

Update the send to email address for Email message

Tuesday, 25 July 2017 07:29

Search Email Messages in C#, VB.NET

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:

Search Email Messages in C#, VB.NET

Full code:

[C#]
//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);
[VB.NET]
'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)
Thursday, 20 July 2017 07:00

Delete Email messages in C#, VB.NET

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);

Delete Email messages in C#, VB.NET

Full code:

[C#]
//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);
[VB.NET]
'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 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)

Spire.Doc included a variety of WordArt types in the ShapeType enum. In order to create WordArt in Word, initialize an instance of ShapeObject and specify the WordArt type and content. The following sections show you how to create WordArt using Spire.Doc step by step.

Step 1: Create an instance of Document class.

Document doc = new Document();

Step 2: Add a section, add a paragraph in section.

Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

Step 3: Create a ShapeObject instance and specify TextWave4 as the ShapeType. Specify the content of WordArt.

ShapeObject shape= paragraph.AppendShape(120, 30, ShapeType.TextWave4);
shape.WordArt.Text = "Thanks for reading.";

Step 4: Set the position, fill color and stroke color of the shape (WordArt).

shape.VerticalPosition = 80;
shape.HorizontalPosition = 170;
shape.FillColor = System.Drawing.Color.Red;
shape.StrokeColor = System.Drawing.Color.Yellow;

Step 5: Save the file.

doc.SaveToFile("output.docx", FileFormat.Docx2013);

Output:

How to Create WordArt in Word in C#, VB.NET

Full Code:

[C#]
Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

ShapeObject shape= paragraph.AppendShape(120, 30, ShapeType.TextWave4);
shape.VerticalPosition = 80;
shape.HorizontalPosition = 170;
shape.WordArt.Text = "Thanks for reading.";
shape.FillColor = System.Drawing.Color.Red;
shape.StrokeColor = System.Drawing.Color.Yellow;

doc.SaveToFile("output.docx", FileFormat.Docx2013);
[VB.NET]
Dim doc As New Document()
Dim section As Section = doc.AddSection()
Dim paragraph As Paragraph = section.AddParagraph()

Dim shape As ShapeObject = paragraph.AppendShape(120, 30, ShapeType.TextWave4)
shape.VerticalPosition = 80
shape.HorizontalPosition = 170
shape.WordArt.Text = "Thanks for reading."
shape.FillColor = System.Drawing.Color.Red
shape.StrokeColor = System.Drawing.Color.Yellow

doc.SaveToFile("output.docx", FileFormat.Docx2013)
Thursday, 13 July 2017 02:33

Extract message contents in C#, VB.NET

This article illustrates how to get message contents such as from address, send to address, subject, date and the body of the message by using Spire.Email.

Code snippets of how to extract the message contents:

Step 1: Load the mail message.

MailMessage mail = MailMessage.Load("Sample.msg");

Step 2: Create a new instance of StringBuilder.

StringBuilder sb = new StringBuilder();

Step 3: Get the message contents as we want.

//get the From address
sb.AppendLine("From:");
sb.AppendLine(mail.From.Address);

//get the To address
sb.AppendLine("To:");
foreach (MailAddress toAddress in mail.To)
{
    sb.AppendLine(toAddress.Address);
}

//get the date
sb.AppendLine("Date:");
sb.AppendLine(mail.Date.ToString());

//get the subject
sb.AppendLine("Subject:");
sb.AppendLine(mail.Subject);

//get the BodyText
sb.AppendLine("Message contents");
sb.AppendLine(mail.BodyText);

//get the BodyHtml
sb.AppendLine("BodyHtml");
sb.AppendLine(mail.BodyHtml);

Step 4: Write all contents in .txt

File.WriteAllText("ExtractMessageContents.txt", sb.ToString());

The extracted message contents in .txt file format.

Extract message contents in C#, VB.NET

Full codes:

[C#]
{
    
    MailMessage mail = MailMessage.Load("Sample.msg");

    StringBuilder sb = new StringBuilder();

    sb.AppendLine("From:");
    sb.AppendLine(mail.From.Address);

    sb.AppendLine("To:");
    foreach (MailAddress toAddress in mail.To)
    {
        sb.AppendLine(toAddress.Address);
    }

    sb.AppendLine("Date:");
    sb.AppendLine(mail.Date.ToString());

    sb.AppendLine("Subject:");
    sb.AppendLine(mail.Subject);

    sb.AppendLine("Message contents");
    sb.AppendLine(mail.BodyText);

    sb.AppendLine("BodyHtml");
    sb.AppendLine(mail.BodyHtml);
        
    File.WriteAllText("ExtractMessageContents.txt", sb.ToString()); 
}
[VB.NET]
Dim mail As MailMessage = MailMessage.Load("Sample.msg")

Dim sb As New StringBuilder()

sb.AppendLine("From:")
sb.AppendLine(mail.From.Address)

sb.AppendLine("To:")
For Each toAddress As MailAddress In mail.[To]
	sb.AppendLine(toAddress.Address)
Next

sb.AppendLine("Date:")
sb.AppendLine(mail.[Date].ToString())

sb.AppendLine("Subject:")
sb.AppendLine(mail.Subject)

sb.AppendLine("Message contents")
sb.AppendLine(mail.BodyText)

sb.AppendLine("BodyHtml")
sb.AppendLine(mail.BodyHtml)

File.WriteAllText("ExtractMessageContents.txt", sb.ToString())
Page 8 of 90