send a string in an email

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
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?
 
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
 
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.
---------------------------
joe_pool_is said:
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?
 
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...
 
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.
 
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..
 
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
 
Back
Top