cjinsocal581
asked on
Updated SendMail using Net.Mail
Here is my old code:
Does anyone have the new way of doing this?
Does anyone have the new way of doing this?
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim mail As New MailMessage
If txtSMTPSVR.Text = "" And txtUSERName.Text = "" And txtUSRPasswd.Text = "" Then
MsgBox("You need to fill out all of the SMTP server information for this option to work properly!", MsgBoxStyle.Information)
Exit Sub
End If
mail.To = txtEmail.Text
mail.From = txtEmail.Text
mail.Subject = "Report from System"
mail.BodyFormat = MailFormat.Text
mail.Body = "The action has been completed."
If chkboxRequiresAuth.Checked = True Then
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", txtUSERName.Text)
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtUSRPasswd.Text)
End If
SmtpMail.SmtpServer = txtSMTPSVR.Text
Try
SmtpMail.Send(mail)
MsgBox("Test message sent successfully!", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(("The following exception occurred: " + ex.ToString()))
'check the InnerException
While Not (ex.InnerException Is Nothing)
MsgBox(("The following InnerException reported: " + ex.InnerException.ToString()))
ex = ex.InnerException
End While
End Try
lstStatus.Items.Insert(0, Now() & " " & "Email setup tested successfully.")
End Sub
The code is ok. What are you looking to get in new code?
ASKER
I just get a lot of "errors" saying it is obsolete.
What namespace are you using? Is it System.Net.Mail?
ASKER
correct.
Which classes exactly it complains about?
ASKER
It says mail is obsolete...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.