Creating a library that sends mail
In this recipe, we will be looking at another area of the System.Net
namespace. We will be using it to create and send an email. Mainly, we will be looking at the SmptClient
class to do the hard work for us.
Getting ready
Make sure you have the latest version of Visual Studio 2017 and all the updates installed. We will be building a .NET Standard 2.0 library to send an email.
How to do it...
- Open Visual Studio 2017.
- Click
File
|New
|Project
to create a project. - In the
New Project
dialog box, expand theOther Project Types
node in the left pane and selectVisual Studio Solutions
. In the right pane, selectBlank Solution
.
- In the
Name:
textbox, typeChapter7.MailBox
and in theLocation:
textbox select a path from the drop-down box or click on theBrowse...
button to locate a path:

- Click
OK
. - Now your
Solution Explorer
(Ctrl + Alt + L) should look like this:

- Now, click the right mouse button on the
Chapter7.MailBox
label in theSolution Explorer
and selectAdd
|New...