Exchange | Blog | Limilabs https://www.limilabs.com/blog Using Limilabs .net components Mon, 19 Sep 2022 07:12:09 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 Office365: Client Credential Flow support for POP/IMAP is coming in June 2022 https://www.limilabs.com/blog/office365-client-credential-flow-pop-imap-coming-june-2022 Tue, 29 Mar 2022 12:13:53 +0000 https://www.limilabs.com/blog/?p=6032 [Update] Client credential flow is now supported: https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp Microsoft is working on bringing OAuth Client Credential Flow support for POP/IMAP for Office365/Exchange. It’s planned to be released in June 2022: https://www.microsoft.com/en-us/microsoft-365/roadmap?filters=&searchterms=70577 Check out currently supported OAuth 2.0 flows OAuth 2.0 with Office365/Exchange IMAP/POP3/SMTP OAuth 2.0 password grant with Office365/Exchange IMAP/POP3/SMTP OAuth 2.0 device flow with […]

The post Office365: Client Credential Flow support for POP/IMAP is coming in June 2022 first appeared on Blog | Limilabs.

]]>
[Update]

Client credential flow is now supported:

https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp


Microsoft is working on bringing OAuth Client Credential Flow support for POP/IMAP for Office365/Exchange. It’s planned to be released in June 2022:

https://www.microsoft.com/en-us/microsoft-365/roadmap?filters=&searchterms=70577

Check out currently supported OAuth 2.0 flows

The post Office365: Client Credential Flow support for POP/IMAP is coming in June 2022 first appeared on Blog | Limilabs.

]]>
Helpful POP3 and IMAP Exchange 2013 links https://www.limilabs.com/blog/helpful-pop3-imap-exchange-2013-links Thu, 18 Feb 2016 13:11:02 +0000 http://www.limilabs.com/blog/?p=5013 Here is the list of some helpful links regarding IMAP and POP3 protocols in Exchange 2013: Enable IMAP4 in Exchange 2013 Enable POP3 in Exchange 2013 POP3 and IMAP4 Public folders in Exchange 2013 Public folders and IMAP Shared mailboxes in Exchange 2013 Accessing shared and delegated mailboxes

The post Helpful POP3 and IMAP Exchange 2013 links first appeared on Blog | Limilabs.

]]>
Here is the list of some helpful links regarding IMAP and POP3 protocols in Exchange 2013:

Enable IMAP4 in Exchange 2013

Enable POP3 in Exchange 2013

POP3 and IMAP4

Public folders in Exchange 2013
Public folders and IMAP

Shared mailboxes in Exchange 2013
Accessing shared and delegated mailboxes

The post Helpful POP3 and IMAP Exchange 2013 links first appeared on Blog | Limilabs.

]]>
Helpful POP3 and IMAP Exchange 2010 links https://www.limilabs.com/blog/helpful-pop3-imap-exchange-2010-links Thu, 18 Feb 2016 13:10:47 +0000 http://www.limilabs.com/blog/?p=5014 Here is the list of some helpful links regarding IMAP and POP3 protocols in Exchange 2010: Enable IMAP4 in Exchange 2010 Enable POP3 in Exchange 2010 Managing POP3 and IMAP4 in Exchange 2010 Understanding POP3 and IMAP4 Public folders and IMAP Accessing shared and delegated mailboxes

The post Helpful POP3 and IMAP Exchange 2010 links first appeared on Blog | Limilabs.

]]>
Here is the list of some helpful links regarding IMAP and POP3 protocols in Exchange 2010:

Enable IMAP4 in Exchange 2010

Enable POP3 in Exchange 2010

Managing POP3 and IMAP4 in Exchange 2010

Understanding POP3 and IMAP4

Public folders and IMAP

Accessing shared and delegated mailboxes

The post Helpful POP3 and IMAP Exchange 2010 links first appeared on Blog | Limilabs.

]]>
Access shared/delegate mailbox of Exchange Server https://www.limilabs.com/blog/access-shared-delegate-mailbox-exchange-server Fri, 04 Apr 2014 13:12:58 +0000 http://www.limilabs.com/blog/?p=4465 1. Enable IMAP and POP3 protocols Make sure you have enabled IMAP and POP3. Following articles can help you with that: How to enable POP3 in Exchange How to enable IMAP in Exchange 2. Turn on basic authentication Using Exchange Management Console Open EMC, expand to Server Configuration->Client Access. In the middle panel, click your […]

The post Access shared/delegate mailbox of Exchange Server first appeared on Blog | Limilabs.

]]>
1. Enable IMAP and POP3 protocols

Make sure you have enabled IMAP and POP3. Following articles can help you with that:

2. Turn on basic authentication

Using Exchange Management Console

  • Open EMC, expand to Server Configuration->Client Access.
  • In the middle panel, click your exchange CAS server, click POP3 and IMAP4 tab, right click IMAP4 and choose properties.
  • In Authentication tab, select “Plain text logon (Basic authentication)”, then click OK.
  • Open services.msc, restart Microsoft Exchange Transport services.

Using Power Shell

Set-IMAPSettings -Server -LoginType PlainTextLogin
Set-POPSettings -Server -LoginType PlainTextLogin

Open services.msc, restart Microsoft Exchange Transport services.

3. Add permissions to the shared mailbox

Give one user full access permission to the shared mailbox:

Add-MailboxPermission Shared.Mailbox1 -user John.Doe -AccessRights FullAccess

This also can be configured from EMC (Exchange Management Console) gui, by selecting the mailbox and clicking on “Manage Full Access Permission…” at the right pane of the window.

Note: You can not add permissions for user without mailbox, Powershell is the only option in such case.

4. Access the shared mailbox

Exchange 2003

Use the following user format DomainName\Username\SharedMailboxAlias (note the use of SharedMailboxAlias it’s often same as the name but it may be different)
(e.g. DOMAIN\John.Doe\Shared.Mailbox1) to log into the shared mailbox.

Exchange 2007

Install this patch: http://support.microsoft.com/?kbid=949926

Use the following user format DomainName\Username\SharedMailboxAlias (note the use of SharedMailboxAlias it’s often same as the name but it may be different)
(e.g. DOMAIN\John.Doe\Shared.Mailbox1) to log into the shared mailbox.

Exchange 2010, Exchange 2013, Exchange 2016, Exchange 2019

Use the following user format DomainName\Username\SharedMailboxAlias (note the use of SharedMailboxAlias it’s often same as the name but it may be different)
(e.g. DOMAIN\John.Doe\Shared.Mailbox1) to log into the shared mailbox.

Office 365/Exchange Online

You can find more details here: https://www.limilabs.com/blog/shared-mailbox-office365

Use the following user format Username@DomainName\Shared@DomainName

You must use Login method:

client.Login(@"Username@DomainName\Shared@DomainName", "UserPassword"); 

-or- LoginPlain method:

client.LoginPlain("Shared@DomainName", "User@DomainName", UserPassword");

Don’t use UseBestLogin for Office365 shared mailboxes.

Using LoginPLAIN to login as a different user

You can try 3rd parameter of LoginPLAIN to log in as a different user:

using (Imap imap = new Imap) 
{ 
    imap.ConnectSSL("outlook.office365.com"); 
    imap.LoginPLAIN("SharedMailboxAlias", "Username@DomainName", "UserPassword"); 
    //... 
    imap.Close(); 
}

The post Access shared/delegate mailbox of Exchange Server first appeared on Blog | Limilabs.

]]>
Convert Outlook .msg file to MIME format in .NET https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net#comments Mon, 14 Oct 2013 18:59:13 +0000 http://www.limilabs.com/blog/?p=4371 Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications. Reading Outlook .msg file format in .NET Convert Outlook .msg file to MIME format in .NET The MSG file contains information about a saved email file including the date of the message, the […]

The post Convert Outlook .msg file to MIME format in .NET first appeared on Blog | Limilabs.

]]>
Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications.

The MSG file contains information about a saved email file including the date of the message, the subject, who sent it, who received it and the contents of the email associated with the file. If attachments ares included with an email, that information will also be saved within the associated MSG file.

MsgConverter , than can be used to convert .msg files to MIME, is written in pure .NET, it does not require registration or any other components or libraries (including Outlook).

The following code snippet reads .msg file in .NET and saves it using MIME format to disk. MIME is shorthand for Multipurpose Internet Mail Extensions and is an Internet standard used to store and transport email messages.

// C#

using (MsgConverter converter = new MsgConverter(@"c:\outlook1.msg"))
{
    if (converter.Type == MsgType.Note)
    {
        IMail email = converter.CreateMessage();

        // Render message using MIME format to byte array
        byte[] mime = email.Render();

        // Save message to file using MIME message format
        email.Save(@"c:\mime.eml");
    }
}
' VB.NET

Using converter As New MsgConverter("c:\outlook1.msg")
If converter.Type = MsgType.Note Then
    Dim email As IMail = converter.CreateMessage()

	' Render message using MIME format to byte array
	Dim mime As Byte() = email.Render()

	' Save message to file using MIME message format
	email.Save("c:\mime.eml")
    End If
End Using

The post Convert Outlook .msg file to MIME format in .NET first appeared on Blog | Limilabs.

]]>
https://www.limilabs.com/blog/convert-outlook-msg-file-to-mime-format-in-net/feed 2
Reading Outlook .msg file format in .NET https://www.limilabs.com/blog/reading-outlook-msg-file-format-net Mon, 14 Oct 2013 18:44:18 +0000 http://www.limilabs.com/blog/?p=4370 Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications. Reading Outlook .msg file format in .NET Convert Outlook .msg file to MIME format in .NET The MSG file contains information about a saved email file including the date of the message, the […]

The post Reading Outlook .msg file format in .NET first appeared on Blog | Limilabs.

]]>
Files containing the .msg file extension are most commonly created by or saved from within one of the Microsoft Outlook email applications.

The MSG file contains information about a saved email file including the date of the message, the subject, who sent it, who received it and the contents of the email associated with the file. If attachments ares included with an email, that information will also be saved within the associated MSG file.

MsgConverter , than can be used to read .msg files, is written in pure .NET, it does not require registration or any other components or libraries (including Outlook).

The following code snippet reads .msg file in .NET and access its most common properties, such as subject, sender and attachments.

// C#

using (MsgConverter converter = new MsgConverter(@"c:\outlook1.msg"))
{
    if (converter.Type == MsgType.Note)
    {
        IMail email = converter.CreateMessage();

        Console.WriteLine("Subject: {0}", email.Subject);
        Console.WriteLine("Sender name: {0}", email.Sender.Name);
        Console.WriteLine("Sender address: {0}", email.Sender.Address);

        Console.WriteLine("Attachments: {0}", email.Attachments.Count);
        foreach (MimeData attachment in email.Attachments)
        {
            attachment.Save(@"c:\" + attachment.SafeFileName);
        }
    }
}
' VB.NET

Using converter As New MsgConverter("c:\outlook1.msg")
    If converter.Type = MsgType.Note Then
        Dim email As IMail = converter.CreateMessage()

        Console.WriteLine("Subject: {0}", email.Subject)
        Console.WriteLine("Sender name: {0}", email.Sender.Name)
        Console.WriteLine("Sender address: {0}", email.Sender.Address)
        
        Console.WriteLine("Attachments: {0}", email.Attachments.Count)
        For Each attachment As MimeData In email.Attachments
            attachment.Save("c:\" + attachment.SafeFileName)
        Next

    End If
End Using

You can read more on how to access To, Cc, Bcc fields.

The post Reading Outlook .msg file format in .NET first appeared on Blog | Limilabs.

]]>
Copy to public folder: “There is no replica for that mailbox on this server.” https://www.limilabs.com/blog/copy-to-public-folder-there-is-no-replica-for-that-mailbox-on-this-server Sun, 01 Sep 2013 18:11:25 +0000 http://www.limilabs.com/blog/?p=4186 When copying an mail from the personal folder to a Public folder, you may receive “There is no replica for that mailbox on this server.” error. This error is generated by Exchange server and unfortunately this is the Exchange limitation. Here’s Microsoft’s response to this problem: Copying from user mailboxes to public folders does not […]

The post Copy to public folder: “There is no replica for that mailbox on this server.” first appeared on Blog | Limilabs.

]]>
When copying an mail from the personal folder to a Public folder, you may receive “There is no replica for that mailbox on this server.” error.

This error is generated by Exchange server and unfortunately this is the Exchange limitation. Here’s Microsoft’s response to this problem:

Copying from user mailboxes to public folders does not work with Exchange IMAP4.
Your users need to copy the message to a personal folder and then back up to the public folder (append) or forward it to an address that gets archived to a public folder.

Workaround

It seems the only way to workaround this is by downloading a message and uploading it to public folder. Important thing is that you don’t need to parse email message at all – you just download and upload raw eml data. Please also note that public folder may be in fact stored on a another IMAP server instance (different server address) – this is usually indicated during logon with REFERRAL error.

// C#

using(Imap imap = new Imap())
{
    imap.Connect("imap.example.com");   // or ConnectSSL for SSL
    imap.UseBestLogin("user", "password");

    imap.SelectInbox();
    List<long> uids = imap.Search(Flag.All);

    foreach (long uid in uids)
    {
        var eml = imap.GetMessageByUID(uid);
        IMail email = new MailBuilder().CreateFromEml(eml);

        if (email.Subject.Contains("[REF"))
            UploadToPublic(email);
    }
    imap.Close();
}
' VB.NET

Using imap As New Imap()
	imap.Connect("imap.example.com")	' or ConnectSSL for SSL
	imap.UseBestLogin("user", "password")

	imap.SelectInbox()
	Dim uids As List(Of Long) = imap.Search(Flag.All)

	For Each uid As Long In uids
		Dim eml = imap.GetMessageByUID(uid)
		Dim email As IMail = New MailBuilder().CreateFromEml(eml)

		If email.Subject.Contains("[REF") Then
			UploadToPublic(email)
		End If
	Next
	imap.Close()
End Using

Here is the body of UploadToPublic method:

// C# code

private void UploadToPublic(IMail email)
{
    using (Imap imap = new Imap())
    {
        imap.Connect("server");  // or ConnectSSL for SSL
        imap.Login("user", "password");
    
        imap.UploadMessage("#Public/Cases", email);
    
        imap.Close();
    }
}
' VB.NET code

Private Sub UploadToPublic(email As IMail)
	Using imap As New Imap()
		imap.Connect("server")
		' or ConnectSSL for SSL
		imap.Login("user", "password")

		imap.UploadMessage("#Public/Cases", email)

		imap.Close()
	End Using
End Sub

The post Copy to public folder: “There is no replica for that mailbox on this server.” first appeared on Blog | Limilabs.

]]>
A connection attempt failed https://www.limilabs.com/blog/connection-attempt-failed https://www.limilabs.com/blog/connection-attempt-failed#comments Mon, 15 Nov 2010 13:26:30 +0000 http://www.limilabs.com/blog/?p=1587 If you are getting following or similar exception: “A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond” or “No connection could be made because the target machine actively refused it.” most likely you provided incorrect server, […]

The post A connection attempt failed first appeared on Blog | Limilabs.

]]>
If you are getting following or similar exception:
“A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond” or “No connection could be made because the target machine actively refused it.” most likely you provided incorrect server, port, and SSL usage configuration to Connect, or ConnectSSL methods.

Default ports for email protocols are:

Plain text SSL/TLS
IMAP 143 993
POP3 110 995
SMTP 587 or 25 465

Most email providers (like Gmail, Hotmail, Yahoo and others) use default ports. Connect() and ConnectSSL() and fluent interface use those ports by default.

Please ask your email server administrator for server, port, and SSL/TLS usage, if those are not standard there is no way you can guess them.

Please also make sure that:

  • your application has enough security permissions to establish connection to the server.
  • you are using correct client class with protocol you plan to use (Pop3 class with POP3 protocol, Imap class with IMAP, and Smtp class with SMTP protocol)
  • you use correct port numbers, and rely on parameter-less Connect() and ConnectSSL() methods (they use default ports) whenever possible
  • you are using ConnectSSL when you require SSL/TLS, and Connect when you don’t
  • firewall and antivirus software are disabled or configured correctly (this includes Windows Defender)
  • the protocol you are trying to use is enabled on the server. Exchange or Gmail can have some protocols disabled by default

Following articles can help you with that:

Connecting using default ports

Plain text mode

Establishing connection using default port is simple, you just need to use Connect method:

// C#

client.Connect("mail.example.com");
' VB.NET

client.Connect("mail.example.com")

Implicit SSL/TLS mode

If SSL encryption is required, use ConnectSSL method:

// C#

client.ConnectSSL("mail.example.com");
' VB.NET

client.ConnectSSL("mail.example.com")

Explicit SSL mode (aka TLS)

If your server requires explicit SSL/TLS (sometimes called TLS), you need to connect using Connect method and then use StartTLS method:

// C#

client.Connect("mail.example.com");
client.StartTLS();
' VB.NET

client.ConnectSSL("mail.example.com")
client.StartTLS()

Connecting using non-standard ports

If you need to specify different port just use overloaded version of Connect or ConnectSSL method:

// C#

client.Connect("mail.example.com", 999);
' VB.NET

client.Connect("mail.example.com", 999)

If SSL/TLS encryption is required:

// C#

client.ConnectSSL("mail.example.com", 999);
' VB.NET

client.ConnectSSL("mail.example.com", 999)

If you need to specify different port using fluent interface use OnPort() method:

// C# version

Mail.Text(@"Hello")
  .To("to@mail.com")
  .From("from@mail.com")
  .Subject("Subject")
  .UsingNewSmtp()
  .Server(_server)
  .WithSSL()
  .OnPort(443)
  .WithCredentials("user", "password")
  .Send();

SSL/TLS

Please look at following articles for details:

Some servers require explicit SSL/TLS (sometimes called TLS). Usually this triggers “The handshake failed due to an unexpected packet format” exception, when you try to connect without SSL/TLS.

If your server uses self-signed certificates you may be getting “The remote certificate is invalid according to the validation procedure” error.

Please read SSL vs TLS vs STARTTLS, if you are confused about those.

Again when in doubt please ask your email server administrator for server, port, and SSL/TLS usage.

The post A connection attempt failed first appeared on Blog | Limilabs.

]]>
https://www.limilabs.com/blog/connection-attempt-failed/feed 8