How to use .NET Core Console app?

Console apps have been around since .NET’s inception i.e. 2002. Over the years, it has had a bit of a windows dressing with additional APIs, integration with .NET Core and the like.

Let’s look at a simple console app written in .NET Core that simply sends an email using the Net.Mail API.

using System;
using System.Net.Mail;

namespace SMTP
    class Program
        static void Main(string[] args)
            Console.WriteLine("The email was sent successfully!");

        private static void SendTestEmail()
            MailMessage mail = new MailMessage("", "");
            SmtpClient client = new SmtpClient
                Port = 587,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = true,
                Host = "",
                Credentials = new System.Net.NetworkCredential("", "MyPassword")
            mail.Subject = "Testing Console App!";
            mail.Body = "How is it going Obi!";

Links to similar blog posts (coming soon!):

About Obi Oberoi

I am a Technology Aficionado who has passion for learning, speaking, reading, helping and hanging out with virtuosos!
This entry was posted in .NET. Bookmark the permalink.