{"id":97,"date":"2019-09-15T07:14:12","date_gmt":"2019-09-15T07:14:12","guid":{"rendered":"http:\/\/sumitjangid.com\/?p=97"},"modified":"2019-10-07T06:12:24","modified_gmt":"2019-10-07T06:12:24","slug":"sending-email","status":"publish","type":"post","link":"http:\/\/sumitjangid.com\/index.php\/2019\/09\/15\/sending-email\/","title":{"rendered":"Sending Email"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>public void SendEmail(string receiver, string subject, string message)\n        {\n            try\n            {\n\n                var senderEmail = new MailAddress(\"noreply@delma-exchange.com\", \"Delma Exchange\");\n                var receiverEmail = new MailAddress(receiver, \"Client\");\n                var password = \"******\";\n                var sub = subject;\n                var body = message;\n                var smtp = new SmtpClient\n                {\n                    Host = \"smtp.office365.com\",\n                    Port = 587,\n                    EnableSsl = true,\n                    DeliveryMethod = SmtpDeliveryMethod.Network,\n                    UseDefaultCredentials = false,\n                    Credentials = new NetworkCredential(senderEmail.Address, password)\n                };\n                using (var mess = new MailMessage(senderEmail, receiverEmail)\n                {\n                    Subject = subject,\n                    Body = body\n                })\n                {\n                   \/\/ Add a carbon copy recipient.\n                    MailAddress copy = new MailAddress(\"Notification_List@abc.com\");\n                    mess.CC.Add(copy);\n                    smtp.Send(mess);\n              }\n\n            }\n            catch (Exception e)\n            {\n                Console.WriteLine(e);\n            }\n\n        }<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,2],"tags":[],"_links":{"self":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/97"}],"collection":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":4,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":183,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions\/183"}],"wp:attachment":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}