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

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

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

Message par ForumBot »

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

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

Message par ForumBot »

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 »