Hello guys,
I have a simple asp.net form and ideally, upon submission, I'd like to forward the form data to an email address. Here is the form:
<div class="contactForm">
<h2>Contact me</h2>
<div class="form">
<div class="control-group">
<label class="control-label" for="title">Title</label>
<div class="controls">
<select id="title" runat="server">
<option>Mr</option>
<option>Ms</option>
<option>Miss</option>
<option>Mrs</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input runat="server" type="text" id="name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input id="email" runat="server" type="text" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="enquiry">Enquiry</label>
<div class="controls">
<textarea id="enquiry" runat="server" type="text"></textarea>
</div>
</div>
<div class="submitButton">
<input id="submitForm" type="submit" value="Submit" runat="server" onserverclick="submitData">
<div class="clear"></div>
</div>
</div>
</div>
Now, I had a look around the net, and found an interesting tutorial - not tested - http://www.mikesdotnetting.com/article/41/send-form-content-by-email-in-asp-net which I was planning to try. There is one thing though, he uses this script:
using (MailMessage message = new MailMessage())
{
message.From = new MailAddress(YourEmail.Text.ToString());
message.To.Add(new MailAddress("me@domain.com"));
message.CC.Add(new MailAddress("copy@domain.com"));
message.Subject = "Message via My Site from " + YourName.Text.ToString();
message.Body = Comments.Text.ToString();
SmtpClient client = new SmtpClient();
client.Host = "127.0.0.1";
client.Send(message);
}
and I'm not sure where to get the values for the below, as I'm developing from localhost
message.To.Add(new MailAddress(""));
message.CC.Add(new MailAddress(""));
client.Host = "";
Any idea?
EDIT: I mean, does is make any difference what email provider I'm trying to forward the email to, or is it irrelevant? I'd like it to go to a gmail address