Last post Jul 30, 2014 04:44 PM by Afzaal.Ahmad.Zeeshan
Jul 30, 2014 10:17 AM|hardweezy|LINK
I know the webmail helper helps with sending mails from your application. What about receiving mails from a contact form, a feedback form..
How do I go about that....
Jul 30, 2014 10:31 AM|wavemaster|LINK
Those aren't really emails. They are forms, contact form and feedback
You would need a third party provider to receive email, if you want to integrate with your application.
Jul 30, 2014 02:29 PM|Afzaal.Ahmad.Zeeshan|LINK
If you want to say, that you want to get an Email when a user submits the contact form or some feedback about some data on your website. Then you can use the WebMail helper as you want. Actually WebMail is just a helper that would send the email whenever
you want it to do so. It is upto you, where and when you want it to send the email and what content must be added to it in order to get the actual content that user wants to send to you through that form.
I would go with only the Contact form and I would give you a details about how you can do this job and get the Email when user sends some information to you. You can use this data and make up a Feedback service in your ASP.NET Web App.
First of all, you create a form to allow the user to add in the details about himself or the message that he wants to send to you.
<input type="text" name="name" id="name" />
<input type="email" name="email" id="email" />
<textarea name="message" id="message"></textarea>
That was the code required to create a simple Contact form that would do the work. Now, the real thing comes in the Server-side code when this block is executed (form is submitted). That code would be like this
var name = Request.Form["name"];
var email = Request.Form["email"];
var message = Request.Form["message"];
// WebMail settings
// you donot need to do these, if already done in _AppStart.cshtml
WebMail.UserName = "your-user-name";
WebMail.From = "shown-in-email";
WebMail.Password = "password";
WebMail.SmtpServer = "your-user-name"; // smtp.gmail.com for gmail
WebMail.SmtpPort = 25; // well, works with most
WebMail.EnableSsl = true; // required for most of the servers
// send email with the details. '@' is used to create multiline strings in ASP.NET
subject: name + " contacted",
body: name + "has contacted the service. His email account is: " + email +
".He sent the following message: \n" + message
This would now, send the email to your email account with the Subject of the [username] Contacted, and the body would include his name, email and the message.
Actually this is not an ideal case to send the email because it includes the data, but no other information. You can add more and more data to the body to make the Email beautiful. You can get the idea, that you want send the Email whereever you want from.
You can include as much detail as you want to be added. This way, at any instance of your App, you can send the information back to your inbox with the required details and it won't take time writing the code either, thanks to ASP.NET.
Good luck! :-)
Jul 30, 2014 03:12 PM|hardweezy|LINK
I would like the sender's email address be included as from
Not my email address repeating itself in the from label and to label
Jul 30, 2014 04:44 PM|Afzaal.Ahmad.Zeeshan|LINK
You can simply edit the code I provided you with then. I already told you, you can change the code to make it a fit for your needs. I have not provided the perfect or ideal code, I have tried to teach you how to write the code to get the email when user
contacts you or sends a feedback. That was my intent.