The exact error I am getting in Visual Studio 2012 is:
error BC30456: 'Dispose' is not a member of 'System.Net.Mail.SmtpClient'.
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Port = 25
SmtpServer.Host = MYHOST.com"
mail = New MailMessage()
mail.From = New MailAddress("MYADDRESS@DOMAIN.com")
mail.To.Add("RECIPIENT@DOMAIN.com")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail"
SmtpServer.Send(mail)
SmtpServer.Dispose()
This should be an obvious error. You would think I was using .net framework 3.5 or lower as Dispose()
was only added as a member to SmtpClient in .net 4.0. However, I am using 4.0!
In the website property pages it states 4.0. Is there somewhere else that I need to set as 4.0? Compiler settings somewhere maybe?