Connect to MS Exchange Server & List Messages from Inbox Folder using IMAP

This technical tip explains how developers can connect and list messages from Inbox folder of Microsoft Exchange Server using IMAP protocol. Microsoft Exchange Server supports the IMAP protocol for accessing items in a mailbox. Use Aspose.Email's ImapClient class to connect to the Exchange Server using IMAP protocol. This article shows how. To connect to an Exchange Server using IMAP, please first, make sure that IMAP services are enabled for your Exchange Server, Open the Control Panel, Go to Administrator Tools, then Services, Check the status of the Microsoft Exchange IMAP4 service and If it is not already running, enable/start it. To View C# and VB.NET samples and other details please visit the main page.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Below is the sample source code to connect and list messages from Inbox folder of Microsoft Exchange Server using IMAP protocol.
//[C#]
// Connect to Exchange Server using ImapClient class
ImapClient imapClient = new ImapClient("ex07sp1", "Administrator", "Evaluation1");
imapClient.Connect(true);
// Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox);
// Get the list of messages
ImapMessageInfoCollection msgCollection = imapClient.ListMessages();
foreach (ImapMessageInfo msgInfo in msgCollection)
{
    Console.WriteLine(msgInfo.Subject);
}
// Disconnect from the server
imapClient.Disconnect();
 
//[VB.NET]
Connect to Exchange Server using ImapClient class
Dim imapClient As ImapClient = New ImapClient("ex07sp1", "Administrator", "Evaluation1")
imapClient.Connect(True)
Select the Inbox folder
imapClient.SelectFolder(ImapFolderInfo.InBox)
Get the list of messages
Dim msgCollection As ImapMessageInfoCollection = imapClient.ListMessages()
For Each msgInfo As ImapMessageInfo In msgCollection
    Console.WriteLine(msgInfo.Subject)
Next msgInfo
Disconnect from the server
imapClient.Disconnect()
//Programming Samples for SSL
//If the Exchange Server uses SSL, modify the above code as follows:
//[C#]
private void ConnectUsingSSL()
{
// Connect to Exchange Server using ImapClient class
ImapClient imapClient = new ImapClient("ex07sp1", 993, "Administrator", "Evaluation1", new RemoteCertificateValidationCallback(RemoteCertificateValid
ationHandler));
X

Url: http://www.aspose.com/.net/email-component.aspx

Language: C# | User: Sheraz Khan | Created: Mar 19, 2014 | Tags: Connect to an Exchange Server, list messages from Inbox folder, Microsoft Exchange Server, Connect to an Exchange using IMAP, Microsoft Exchange IMAP4 service, Exchange Server uses SSL Connect to an Exchange Server list messages from Inbox folder Microsoft Exchange Server Connect to an Exchange using IMAP Microsoft Exchange IMAP4 service Exchange Server uses SSL