Last post Mar 22, 2017 01:58 PM by dlchase
Mar 22, 2017 01:54 PM|dlchase|LINK
We have used the code below in our .net 4 websites but is not working in our new websites. The line with "...New NetworkCredential()" apparently is invalid. What is the replacement for setting mail credentials before sending? Below is our code.
'(4) Create the SmtpClient object
Dim strServer As String = "smtp.office365.com"
Dim smtp As New SmtpClient(strServer, 587)
smtp.DeliveryMethod = SmtpDeliveryMethod.Network
'below line must be before the network credentials
smtp.UseDefaultCredentials = False
smtp.Credentials = New NetworkCredential(strAddress, strEpw)
smtp.EnableSsl = True
'(5) Send the MailMessage (will use the Web.config settings)
Mar 22, 2017 01:58 PM|dlchase|LINK
Ignore this. I forgot to import System.Net