Last post Sep 24, 2018 07:49 AM by PatriceSc
Sep 18, 2018 09:29 PM|Omar27|LINK
i have in the footer of the page a textbox ( first name ) and an other textbox ( email ) and textarea ( message ),
i want to send an email to an adress (only one adresse) when the areas above are filled and clicked on "send message"
Thanks in advance.
Sep 19, 2018 02:43 AM|Brando ZWZ|LINK
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to send the email from the textbox to another address's email?
If this is your requirement, I suggest you could consider using System.Net.Mail help you to achieve your requirement.
More details, you could refer to below demo codes:
Notice: You should set the email's password in the code-behind.
first name : <asp:TextBox ID= "name" runat="server"></asp:TextBox><br/>
email name: <asp:textbox id="email" runat="server" /><br/>
<asp:textbox id="txtBody" runat="server" height="150px" textmode="multiline" /><br/>
<asp:button id="btn_SendMessage" runat="server" onclick="btn_SendMessage_Click" text="Send message" /><br/>
<asp:label id="Label1" runat="server" text="" />
protected void btn_SendMessage_Click(object sender, EventArgs e)
SmtpClient smtpClient = new SmtpClient("smtp.office365.com", 25);
smtpClient.EnableSsl = true;
smtpClient.Credentials = new System.Net.NetworkCredential("the email account", "password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage(email.Text, "to email");
mailMessage.Subject = name.Text;
mailMessage.Body = txtBody.Text;
Label1.Text = "Message sent";
catch (Exception ex)
Label1.Text = ex.ToString();
Sep 20, 2018 05:18 PM|Omar27|LINK
like i have in the bottom of my website a division i have inside it a 3 textboxes that if the user want to send a message to the company who has the website i work on, he has to fill the textbox1 with his name, the 2nd with his email, the 3rd with the message
he wants to send, so when he clicks on the button "send message" it should a message to the company's email
If you need any more explanation please ask me again.
Sep 21, 2018 08:46 AM|Brando ZWZ|LINK
I still couldnn't understand your issue clearly.
Could you please tell me which is From email? User's Email or Company Email?
If you want to send the Email from user to your company, you should add a textbox to let user type in his password.
Sep 21, 2018 04:44 PM|Omar27|LINK
Hi Brando ZWZ,
i made a website for the company i had a 2 months internship inside, so in the bottom of the website i have a contact section which the visitor of the website can contact the company so in the contact section he has a field
to fill with his name and another field for his email and the 3rd field for the message ha wantss to send to the company's email.
i hope you understand now more.
Sep 24, 2018 07:15 AM|Nan Yu|LINK
Hi OMAR27 ,
You can use asp:RequiredFieldValidator to make sure the user enter his name/email/message :
<asp:Textbox id="txtLastName" runat="server"></asp:Textbox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
ErrorMessage="Last name is a required field."
When user click the submit button , in code behind , you can get the information from textboxes , send email to your own mailbox with user's information , in this scenario , you should provide your email credential to complete the email sending behavior
. To use SmtpClient to send emails , you could refer to above code sample .
Sep 24, 2018 07:49 AM|PatriceSc|LINK
The main point is to configure the mail server you'll use to send those mails:
Using the MialMessage/SmtpClient classes is quite straigtforward. Knowing what happens when you try suggested code would help to understand which kind of help is neeed. For know my guess is that you have to coinfigure mail settings (it's sometimes done on
code, but the SmtpClient class will read automatically settings found in the web.config file).