I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2:
smtpClient.Send(mailMsg);
smtpClient is a reference to SmtpClient (I have the relevant references added), and likewise for mailMsg (is MailMessage) – there are no errors stating anything like check for missing assemblies.
However, I keep getting an error saying that I have the incorrect no of overloads, when SmtpClient takes either a MailMessage object or the To address, From address, Subject, etc.
Why doesn’t this code work? Totally confused.
Thanks
There are two different
MailMessageclasses :System.Net.Mail.MailMessage, andSystem.Web.Mail.MailMessage. The one in theSystem.Web.Mailnamespace is obsolete, and is not compatible withSmtpClient. Make sure you’re using the correct class, perhaps you have ausing System.Web.Mailclause in your code