|
-
Jan 6th, 2009, 04:55 AM
#1
Thread Starter
Hyperactive Member
Re: Send email with textbox values
 Originally Posted by Fishcake
Sending email is reasonably easy with asp.net and is well described in this article.
As for the configuration details of the server you will need those details off someone who administers your SMTP server.
Hi this is my code,
is this correct...?
protected void btnSubmit_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = txtemail.Text;
mail.Subject = txtname.Text;
mail.Body = txtmessage.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
}
by checking this i'll have a error on the SmtpMail.Send(mail);
tel me
Last edited by mendhak; Jan 6th, 2009 at 06:57 AM.
-
Jan 6th, 2009, 06:29 AM
#2
Junior Member
Re: Send email with textbox values
you need to actually fill in the "localhost" part, and for that it is very difficult to work with mail.From = txtEmail.Text, because different people use different smtp hosts.
The easiest way (and probably the only way?) is to bypass this using a dummy email adress.
For Example: For my school project I created a free G-Mail account [email protected].
(Why gmail? 1. because it's free, 2. because it uses a different port than port 25, unlike most other free hosts, and part 25 is sometimes blocked by some people's ISP)
Then in your code you say something like:
Code:
mail.From = "[email protected]"
smtpClient sendMail = new smtpClient("smtp.gmail.com","587")
SendMail.Credentials = New NetworkCredential("[email protected]", "yourpassword")
//you need this enabled, because gmail needs to verfiy you are the owner of the account
sendMail.Enablessl = true
sendMail.send(mail)
Forgive me if the syntax isn't 100% correct, I haven't got much time on hands right now.
Edit: to have the persons adress, you can always put it in the replyTo properte (mail.ReplayTo = txtEmail.text)
-
Jan 6th, 2009, 06:38 AM
#3
Re: Send email with textbox values
 Originally Posted by Arsenal
you need to actually fill in the "localhost" part, and for that it is very difficult to work with mail.From = txtEmail.Text, because different people use different smtp hosts.
There's nothing wrong with that if your SMTP server is on the same machine as the webserver.
You can also allow any from address if the SMTP server is acting as a relay although admittedly this isn't usually desirable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|