MailKit C# SmtpClient.Connect() to Office 365 generating exception: "An existing connection was forcibly closed by the remote host"

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

MailKit C# SmtpClient.Connect() to Office 365 generating exception: "An existing connection was forcibly closed by the remote host"

Message par Clippy »

MailKit C# SmtpClient.Connect() to Office 365 generating exception: "An existing connection was forcibly closed by the remote host"
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: MailKit C# SmtpClient.Connect() to Office 365 generating exception: "An existing connection was forcibly closed by the remote host"

Message par Clippy »

Got another error after posting this question which led me to the answer:


Handshake failed due to an unexpected packet format

The solution is to connect to Office 365 like this instead:

```
smtpClient.Connect("smtp.office365.com", 587, SecureSocketOptions.StartTls);

```
Répondre

Revenir à « Excel & VBA »