I have found a solution but I am getting an error message. I am also confused as to what username and password i should use because this web app will not be used by me but rather various users.
This is my code in Button Click:
Protected Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
Try
Dim mailsubject As String = txtSubject.Text
Dim mailbody As String = txtMessage.Text
Dim mailmsg As MailMessage = New MailMessage(txtFrom.Text, txtTo.Text)
mailmsg.Subject = mailsubject
mailmsg.Body = mailbody
mailmsg.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()
smtp.Send(mailmsg)
Catch
End Try
End Sub
This is my code in my web.config file:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp-mail.outlook.com" enableSsl="true" port="587" userName="*****" password="******"/>
</smtp>
</mailSettings>
</system.net>
This is my error message that i am getting:
Below is the error message that I am getting: System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [PR0P264CA0207.FRAP264.PROD.OUTLOOK.COM]'