{"id":1546,"date":"2018-04-07T17:17:04","date_gmt":"2018-04-07T21:17:04","guid":{"rendered":"http:\/\/www.ObiOberoi.com\/?p=1546"},"modified":"2018-04-07T17:17:04","modified_gmt":"2018-04-07T21:17:04","slug":"how-to-use-net-core-console-app","status":"publish","type":"post","link":"https:\/\/obioberoi.com\/?p=1546","title":{"rendered":"How to use .NET Core Console app?"},"content":{"rendered":"<p>Console apps have been around since .NET&#8217;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.<\/p>\n<p>Let&#8217;s look at a simple console app written in .NET Core that simply sends an email using the Net.Mail API.<\/p>\n<pre>using System;\nusing System.Net.Mail;\n\nnamespace SMTP\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            SendTestEmail();\n            Console.WriteLine(\"The email was sent successfully!\");\n            Console.ReadLine();\n        }\n\n        private static void SendTestEmail()\n        {\n            MailMessage mail = new MailMessage(\"Obi@eOberoi.com\", \"ooberoi@hotmail.com\");\n            SmtpClient client = new SmtpClient\n            {\n                Port = 587,\n                DeliveryMethod = SmtpDeliveryMethod.Network,\n                UseDefaultCredentials = true,\n                Host = \"smtp.google.com\",\n                Credentials = new System.Net.NetworkCredential(\"Obi@gmail.com\", \"MyPassword\")\n            };\n            \n            mail.Subject = \"Testing Console App!\";\n            mail.Body = \"How is it going Obi!\";\n            client.Send(mail);\n        }\n        \n    }\n<\/pre>\n<p>Links to similar blog posts (<strong>coming soon!<\/strong>):<\/p>\n<ul>\n<li><a href=\"http:\/\/www.obioberoi.com\/2018\/04\/14\/how-to-publish-and-execute-a-net-core-console-app\/\">Publishing .NET Core app<\/a><\/li>\n<li><a href=\"http:\/\/www.obioberoi.com\/2018\/04\/21\/how-to-create-an-exe-using-net-core-console-app\/\">Creating an .EXE in a Console App<\/a><\/li>\n<li>Consuming Console App&#8217;s DLL externally (using Batch program)<\/li>\n<li>Sending Email blasts using SendGrid<\/li>\n<li>Using Windows Task Scheduler<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Console apps have been around since .NET&#8217;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&#8217;s look at a simple console app written &hellip; <a href=\"https:\/\/obioberoi.com\/?p=1546\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1546","post","type-post","status-publish","format-standard","hentry","category-net"],"_links":{"self":[{"href":"https:\/\/obioberoi.com\/index.php?rest_route=\/wp\/v2\/posts\/1546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obioberoi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obioberoi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obioberoi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obioberoi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1546"}],"version-history":[{"count":0,"href":"https:\/\/obioberoi.com\/index.php?rest_route=\/wp\/v2\/posts\/1546\/revisions"}],"wp:attachment":[{"href":"https:\/\/obioberoi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obioberoi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obioberoi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}