{"id":1623,"date":"2011-10-10T10:59:51","date_gmt":"2011-10-10T14:59:51","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=1623"},"modified":"2011-10-10T11:25:03","modified_gmt":"2011-10-10T15:25:03","slug":"vb-net-send-email-2","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2011\/10\/vb-net-send-email-2\/","title":{"rendered":"VB.NET &#8211; Send Email"},"content":{"rendered":"<p>Send email using web form &#8211; user defines smtp settings.<\/p>\n<pre>send-email.aspx\r\n<code> \r\nTo: <input type=\"text\" value=\"recipient@someemail.com\" style=\"width:180px\"\/>\r\nFrom: <input type=\"text\" value=\"you@gmail.com\" style=\"width:180px\"\/>\r\nSMTP Server: <input type=\"text\" value=\"mail.gmail.com\" style=\"width:180px\"\/>\r\nSubject: <input type=\"text\" value=\"Email subject\" style=\"width:180px\"\/>\r\nAttachment: <input type=\"text\" value=\"attachment\" style=\"width:180px\"\/><input type=\"button\" value=\"browse\"\/>\r\nBody: \r\n<textarea style=\"width: 400px; height: 60px;\">You email body here<\/textarea>\r\nAction: <input type=\"button\" value=\"Send Email\" \/>\r\n\r\nStatus: [labelEmailSent]\r\n<\/code>\r\n<\/pre>\n<pre>\r\nsend-email.aspx.vb\r\n<code>\r\nImports System.Net.Mail\r\n\r\nPartial Class Send_Email\r\n    Inherits System.Web.UI.Page\r\n    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) \r\n                                                              Handles btnSubmit.Click\r\n        Try\r\n            Dim SendFrom As MailAddress = New MailAddress(txtFrom.Text)\r\n            Dim SendTo As MailAddress = New MailAddress(txtTo.Text)\r\n\r\n            Dim MyMessage As MailMessage = New MailMessage(SendFrom, SendTo)\r\n\r\n            MyMessage.Subject = txtSubject.Text\r\n            MyMessage.Body = txtBody.Text\r\n\r\n            Dim attachFile As New Attachment(txtAttachmentPath.Text)\r\n            MyMessage.Attachments.Add(attachFile)\r\n\r\n            Dim emailClient As New SmtpClient(txtSMTPServer.Text)\r\n            emailClient.Send(MyMessage)\r\n\r\n            litStatus.Text = \"Message Sent\"\r\n        Catch ex As Exception\r\n            litStatus.Text = ex.ToString()\r\n        End Try\r\n    End Sub\r\nEnd Class\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Send email using web form &#8211; user defines smtp settings. send-email.aspx To: From: SMTP Server: Subject: Attachment: Body: You email body here Action: Status: [labelEmailSent] send-email.aspx.vb Imports System.Net.Mail Partial Class Send_Email Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim SendFrom As MailAddress = New MailAddress(txtFrom.Text) Dim SendTo [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,16],"tags":[19,145,27],"class_list":["post-1623","post","type-post","status-publish","format-standard","hentry","category-applications","category-net","tag-asp-net","tag-email","tag-form-validation"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1623"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=1623"}],"version-history":[{"count":12,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1623\/revisions"}],"predecessor-version":[{"id":1635,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1623\/revisions\/1635"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=1623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=1623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=1623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}