{"id":317,"date":"2019-08-09T16:25:59","date_gmt":"2019-08-09T15:25:59","guid":{"rendered":"https:\/\/blogs.gre.ac.uk\/cmssupport\/?page_id=317"},"modified":"2019-08-09T16:25:59","modified_gmt":"2019-08-09T15:25:59","slug":"sending-email-using-asp-net","status":"publish","type":"page","link":"https:\/\/blogs.gre.ac.uk\/cmssupport\/application-development\/programming\/asp-net\/sending-email-using-asp-net\/","title":{"rendered":"Sending email using ASP.NET"},"content":{"rendered":"\n<p>The following code samples show the code you need to use in order to send email through ASP.NET using the System.Net.Mail namespace:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using C#<\/h2>\n\n\n\n<p>Note that for the code below to work, you need to add&nbsp;using System.Net.Mail;&nbsp;to the list of &#8216;using&#8217; directives at the top of your code file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">MailMessage mail = MailMessage();\n\nmail.From = new MailAddress(\"username@greenwich.ac.uk\");\n\nmail.To.Add(\"username@greenwich.ac.uk\");\n\nmail.Body = \"Your message here\";\n\nmail.Subject = \"Your subject here\";\n\nSmtpClient client = new SmtpClient();\n\nclient.Host = \"smtp.gre.ac.uk\";\n\nclient.Send(mail);<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using VB<\/h2>\n\n\n\n<p>Note that for the code below to work, you need to add&nbsp;Imports System.Net.Mail&nbsp;to the list of &#8216;Imports&#8217; directives at the top of your code file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Dim mail As MailMessage\n\nmail = New MailMessage\n\nmail.From = New MailAddress(\"username@greenwich.ac.uk\")\n\nmail.To.Add(\"username@greenwich.ac.uk\")\n\nmail.Body = \"Your message here\"\n\nmail.Subject = \"Your subject here\"\n\nDim client As New Mail.SmtpClient\n\nclient.Host = \"smtp.gre.ac.uk\"\n\nclient.Send(mail)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following code samples show the code you need to use in order to send email through ASP.NET using the System.Net.Mail namespace: Using C# Note that for the code below to work, you need to &hellip;<\/p>\n","protected":false},"author":53,"featured_media":0,"parent":49,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-317","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/users\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":0,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/317\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/49"}],"wp:attachment":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/media?parent=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}