Hi Featheriver,
Yes, that's exactly what you need todo: type the following at the top of the file, near the other using statements:
Code:
using System.Net.Mail;
In order to use a type like the MailMessage class you typically need to do two things:
1. Create a project reference to the DLL that contains the type so your project can see the types defined in that DLL.
2. Bring the type "in scope" by adding a using statement.
The first is already done as the DLL that contains the MailMessage class is added by default. The reason you need to explicitly add a using statement has a few reasons:
1. First, it avoids clutter in the IntelliSense list. Imagine you didn't have to include a using statement and instead would see all types defined in all referenced DLLs. You would see hundreds or even thousands of items, making it hard to find the one you need
2. Secondly, it avoids type collisions. The book mentions the System.Web.UI.Page and the Microsoft.Word.Page classes as an example. Both are called Page. Which one would you be referring to if both of them were in scope automatically? By adding a using statement, you explicitly tell the compiler from which namespace you want to use a specific type.
Does this help? It's a bit long answer for something as "yes, add the using statement", but I hope it helps in clarifying why you need all this....
Imar