Dim OMail As New MailMessage() Dim oServer As New SmtpClient Dim name As String Dim theCredential As System.Net.NetworkCredential = New System.Net.NetworkCredential(Email.Text, Password.Text) oServer.Credentials = theCredential name = FName.Text + Lname.Text ' Set recipient email address, please change it to yours OMail.From = New MailAddress(Email.Text) ' Set recipient email address, please change it to yours OMail.To.Add("Example@outlook.com") ' Set email subject OMail.Subject = Subject.Text ' Set email body OMail.Body = Template.Text + Message.Text + "This message was sent by " + name + " @ " + Email.Text ' Your Office 365 SMTP server address, ' You should get it from outlook web access. oServer.Host = "smpt.live.com" ' user authentication should use your 'Email address as the user name. oServer.Credentials = New Net.NetworkCredential(My.Settings.Email, My.Settings.Emailpass) ' Set 587 port oServer.Port = 587 Try strMsg = "start to send Feedback..." & vbCrLf & "Please wait" strTitle = "Sending Email" Ret_type = MsgBox(strMsg, vbOKOnly + vbInformation, strTitle) ' oServer.Send(OMail) ' strMsg = "email was sent successfully!" & vbCrLf & "If a reply is needed you sould get one in the next few days!" strTitle = "Email sent" Ret_type = MsgBox(strMsg, vbOKOnly + vbInformation, strTitle) Catch ex As Exception strMsg = "failed to send email with the following error:" & vbCrLf & vbCrLf & "'" & ex.Message & "'" strTitle = "Critical Error Encountered" Ret_type = MsgBox(strMsg, vbOKOnly + vbCritical, strTitle) End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)