joe_pool_is Posted March 20, 2004 Posted March 20, 2004 We have a basic form online, and we are collecting info with vb.net and asp.net into a string called strOutput. We would like to have this string sent to us in an email, but no one knows how to do that once the button Submit is pressed. Any thoughts? Links? Quote Avoid Sears Home Improvement
mocella Posted March 20, 2004 Posted March 20, 2004 Check out System.Web.Mail namespace. Do a search here, the syntax has been covered before. Quote
Arch4ngel Posted March 23, 2004 Posted March 23, 2004 This one is sure to be the easiest way... but you got to have a SMTP server on your machine or an access to a SMTP Server that DON'T need authentication Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
sj1187534 Posted March 23, 2004 Posted March 23, 2004 I have this code that I used a long time before. This is a class to send an e-mail throught VB.NET ========================================================== Imports System.Web.Mail Public Class SendMail Private emailID As String, thisBody As String, thisSubject As String Private fromAddr as String, Smtp As SmtpMail '======================================================= ' Create a new E-Mail object taking the input parameters: ' toAddr -> E-Mail ID to send the mail to ' fromAddr -> From E-Mail address ' body -> Body of the email as string ' subj -> Subject as string '======================================================= Public Sub New(ByVal to As String, ByVal from As String, ByVal body As String, ByVal subj As String) emailID = to thisBody = body thisSubject = subj fromAddr = from Smtp.SmtpServer = "" ' SMTP server address here End Sub '======================================================= ' Send the E-Mail '======================================================= Public Function Send() Dim msg As MailMessage = New MailMessage msg.Body = thisBody msg.From = fromAddr msg.To = emailID msg.Subject = thisSubject Smtp.Send(msg) End Function End Class ========================================================== In your case, you can use it this way: dim mymail as New SendMail("to@mail.com", "from@mail.com", strOutput, "sample mail") mymail.Send() SJ. --------------------------- We have a basic form online, and we are collecting info with vb.net and asp.net into a string called strOutput. We would like to have this string sent to us in an email, but no one knows how to do that once the button Submit is pressed. Any thoughts? Links? Quote
son Posted April 22, 2004 Posted April 22, 2004 html controls or server controls... hi hope all is well.. i know this might sound stupied but do the controls have to be web controls or they can be html controls .. thanks in advance sonia... Quote
tate Posted April 22, 2004 Posted April 22, 2004 I have used web controls with no problem. By the way, make sure your smtp string is setup based on the web hosts recommendations. Each host may be different. Quote
son Posted April 25, 2004 Posted April 25, 2004 Hi Thanks For Your Reply... Got One Question Can U Explain To Me Exactly What U Mean By Smtp Being Setup Based On The The Web Hosts Recommendation Cause Each Host My Be Different.. The Reason I Am Asking Is Because I Am Quite Green In That Area.. Thanks In Advance.. Quote
tate Posted April 27, 2004 Posted April 27, 2004 If you are personally running a web server then you are in control of setting up the smtp mail server. However, if you utilize a company to host your web pages then all of the email generated from your web page will be processed by the host's smtp server. The web host will most likely provide instructions on how to utilize their smtp server with your ASP.NET pages. Here is what one of my hosts provided to make sure your code was setup properly; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Send Email in ASP.NET The information in this article applies to: ASP.NET Email DETAILS <%@ Page Language="VB" %> <script runat="server"> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage mailMessage.From = "you@yourdomainname.com" mailMessage.To = "someone@somewhere.com" mailMessage.Subject = "This is a sample mail sent from ASP.net Mail Component" mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text mailMessage.body = "Congratulation" & VbCrLf & "If you receive this is, your mail component works" System.Web.Mail.SmtpMail.SmtpServer = "localhost" System.Web.Mail.SmtpMail.Send(mailMessage) lblMessage.text = "Mail Sent" End Sub </script> <html> <body>> <form runat="server"> <asp:Label id="lblMessage" runat="server"></asp:Label> </form> </body> </html> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to the above information you may want to research the following web page; http://www.systemwebmail.com/ Hope this helps you on your journey! Tate Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.