' VB.NET
Using client As New Imap()
client.ConnectSSL("outlook.office365.com")
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using
Using client As New Pop3()
client.ConnectSSL("outlook.office365.com")
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using
Using client As New Smtp()
client.Connect("smtp.office365.com")
client.StartTLS()
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using

Office 365 pre-upgrade

For latest Office 365 pre-upgrade, use the following settings:

On the main screen go to “Options” / “See All Options…”:

Now click the “Settings for POP, IMAP, and SMTP access…” link:

You can find POP, SMTP and IMAP server addresses and settings on the popup window:

Office365 uses default ports for IMAP, POP3 and SMTP protocols. That means that you don’t need to remember port numbers, as Mail.dll .NET email component is going to use correct port numbers by default.

' VB.NET
Using client As New Imap()
client.ConnectSSL("podXXXX.outlook.com")
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using
Using client As New Pop3()
client.ConnectSSL("podXXXX.outlook.com")
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using
Using client As New Smtp()
client.Connect("podXXXX.outlook.com")
client.StartTLS()
client.UseBestLogin("user@domain.onmicrosoft.com", "password")
...
End Using

You can find more details about using implicit and explicit SSL or TLS with email protocols:

Sending email is built into .NET, so there’s no need for 3rd party library, however Mail.dll is much easier to use than SmtpClient,
and much more powerful. Receiving is a bit more complicated. It does require a 3rd party library.

There are two standard protocols for receiving emails IMAP (Internet Message Access Protocol) and POP3 (Post Office Protocol).
Without getting in to much details IMAP is better and offers more features when receiving emails (you can find a detailed IMAP vs POP3 comparison here). We’ll use Imap class to work with this protocol.

As a prerequisite you need to add reference to Mail.dll to your project and import following namespaces:

// C#
using Limilabs.Mail;
using Limilabs.Client.IMAP;

' VB
Imports Limilabs.Mail
Imports Limilabs.Client.IMAP

First thing you need to do is to connect to your IMAP email server. Most servers today require SSL or TLS. We’ll use ConnectSSL(string host) to connect and establish secure channel. This method makes sure correct SSL/TLS versions are used and server certificate are valid:

Finally we need to receive and process those emails. On the server emails are stored in MIME format. GetMessageByUID method receives emails as a raw byte array and MailBuilder class can be used to parse it:

Specification allow using encoded-words in the name (RFC2047 – 5. Use of encoded-words in message headers. (3) )
Encoded words are used to encode non-ASCII characters, for example national characters like umlauts (ä, ö, ü).

RFC2047 imposes no restrictions what characters can be encoded, which means that zero byte (\0) and new lines (\r\n) are valid characters.

Client applications must ensure that such special charters don’t ‘push’ the actual email address (“”test@example.com”) outside of control, in such way, that it becomes not visible.
It is crucial for them to display the email address (test@example.com) no matter what is in the name field.

As part of our ongoing commitment to invest in and provide a scalable ecommerce platform that meets the advancing needs of our client base, we will be conducting planned maintenance to our system next week: