Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is what i have:
XML
<h3>Contact Us</h3>
                            <div>
                                <span><label>NAME</label></span>
                                <span><input name="userName" type="text" class="textbox"></span>
                            </div>
                            <div>
                                <span><label>E-MAIL</label></span>
                                <span><input name="userEmail" type="text" class="textbox"></span>
                            </div>
                            <div>
                                <span><label>MOBILE</label></span>
                                <span><input name="userPhone" type="text" class="textbox"></span>
                            </div>
                            <div>
                                <span><label>SUBJECT</label></span>
                                <span><textarea name="userMsg"> </textarea></span>
                            </div>
                           <div>
                                <span><asp:Button ID="btnSubmit" runat="server" Text="Submit" /></span>
                          </div>
                    </div>


when i click the submit button, i would like to send the information under Name, E-Mail, Mobile and Subject to my email address?
Any ideas??? THANKS
Posted
Comments
phil.o 18-Jun-14 13:41pm    
May I ask you what you did try so far?
'I would like...?' is not a question, I'm afraid.
'Any ideas?' not a valid one, either.
Have you made some basic research on the topic? I found tons of examples in a few seconds; some even hosted on this website in articles section.
ZurdoDev 18-Jun-14 13:54pm    
Where are you stuck?

1 solution

use objects from the System.Net.Mail namespace:

for example:

protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailAddress SendFrom = new MailAddress(txtFrom.Text);
MailAddress SendTo = new MailAddress(txtTo.Text);

MailMessage MyMessage = new MailMessage(SendFrom, SendTo);

MyMessage.Subject = txtSubject.Text;
MyMessage.Body = txtBody.Text;

Attachment attachFile = new Attachment(txtAttachmentPath.Text);
MyMessage.Attachments.Add(attachFile);

SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
emailClient.Send(MyMessage);

litStatus.Text = "Message Sent";
}
catch (Exception ex)
{
litStatus.Text=ex.ToString();
}
}
 
Share this answer
 
Comments
Zieyaad 18-Jun-14 14:14pm    
Christian Sanabaria, thank you for replying. im somewhat new to this so what you sent me looks AMAZING but im kind of stuck. ive tried nearly all week but im getting nowhere, especially now that i want to use html (input). when i click the submit button, i want all the above information to be sent to this email address : kioski@gmail.com

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900