Suddenly frequently problem with sending Mail via Office365 SMTP

Klaus Ketelhut 1 Reputation point
2021-10-29T10:47:59.05+00:00

Is there a problem with microsoft 365 online? Sending bills to customers via an vb.net app. Sometimes sending works fine, sometimes errors occure on every Email or on some oft them.
I use (not complete code but the mainstuff)

Dim Msg As New MailMessage
Dim myCredentials As New System.Net.NetworkCredential
myCredentials.UserName = Username
myCredentials.Password = Password
Msg.IsBodyHtml = AsHTML

Dim mySmtpsvr As New SmtpClient() 'and I send the mails with attached PDF in a loop.
mySmtpsvr.Host = Host
mySmtpsvr.Port = Port
mySmtpsvr.EnableSsl = True
mySmtpsvr.UseDefaultCredentials = False
mySmtpsvr.Credentials = myCredentials
mySmtpsvr.Send(Msg)

It was always working fine since a couple of weeks. The problem seems to be depended on the day maybe time?

Sombody knows?
Thank you very much

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,736 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,580 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Richard Rombaut 11 Reputation points
    2022-01-05T10:25:23.19+00:00

    I think I found the solution: https://stackoverflow.com/questions/28362132/office-365-smtp-starts-firing-net-io-connectionclosed
    Bassicly , adding the line System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 seemed to solve my issue.

    1 person found this answer helpful.

  2. Yi Lu_MSFT 17,461 Reputation points
    2021-11-01T07:00:36.063+00:00

    Hi @Klaus Ketelhut
    The cause of this error may be diverse, I have found an article which talks about this exception:
    https://stackoverflow.com/questions/35751844/smtp-5-7-57-error-when-trying-to-send-email-via-office-365

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

    If you still need further assistance, I suggest you to open a service request in Microsoft 365 admin center for better help.

    145394-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Richard Rombaut 11 Reputation points
    2022-01-05T10:14:24.553+00:00

    Hi,

    Did someone already found a solution for this?
    Im having the exact same issue since a couple of weeks.
    Sometimes it send a couple of mails fine, and sometimes im getting the error : net_io_connectionclosed.

    thnks!

    0 comments No comments

  4. t.saalbach95 1 Reputation point
    2022-02-02T13:00:02.647+00:00

    I added a TImeout of 200000 and I don't get an error message anymore.

    https://learn.microsoft.com/de-de/dotnet/api/system.net.mail.smtpclient.timeout?view=net-6.0