I have a VB.NET application that sends emails to users letting them know something requires their attention.
The mail is generated within the app and sent through a Microsoft 365 Account.
This has worked for years without an issue, however 2 days ago it suddenly stopped working.
I have tested the mail account outside of the app and it works fine.
When I log in to the 365 account there are no items in the outbox or sent items for the last 2 days and no failed email notices in the inbox. Therefore I have concluded the issue must be somehow in the app.
The problem with this is that I have not changed this part of the app for about 2-3 years so don't know why it would stop working.
The code structure is:
Imports System.Net.Mail
Public Class Form1
Private Sub SendEmail()
Dim MS365Email As New MailMessage
MS365Email.To.Add("RECIPIENTEMAIL")
MS365Email.From = New MailAddress("SENDEREMAIL")
MS365Email.Subject = "SUBJECT"
MS365Email.IsBodyHtml = True
MS365Email.Body = "BODYTEXT"
Dim MS365client As New SmtpClient("smtp.office365.com", 587)
MS365Email.Priority = MailPriority.Normal
MS365client.EnableSsl = True
MS365client.UseDefaultCredentials = False
Dim xms365 As New Net.NetworkCredential("USERNAME", "PASSWORD")
MS365client.Credentials = xms365
MS365client.DeliveryMethod = SmtpDeliveryMethod.Network
MS365client.SendAsync(MS365Email, Nothing)
End Sub
End Class
Thanks for any help and suggestions.
JP