Sending email to the specified gmail account by the user (much like feedback page) ASP.Net C# -
the front end
<table> <tr> <td> <asp:textbox id="rec_email" runat="server" readonly="true">mymail@gmail.com</asp:textbox> </td></tr> <tr> <td> <asp:textbox id="vol_name" runat="server" placeholder="your name" font-names="letter gothic std"></asp:textbox> <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" errormessage="please enter name" display="dynamic" controltovalidate="vol_name" setfocusonerror="true"></asp:requiredfieldvalidator> </td> </tr> <tr> <td> <asp:textbox id="sen_email" runat="server" placeholder="your email" font-names="letter gothic std"></asp:textbox> </td></tr> <tr> <td> <asp:textbox id="phone_num" runat="server" placeholder="your number" font-names="letter gothic std"></asp:textbox> </td></tr> <tr> <td> <asp:textbox id="msg_text" runat="server" textmode="multiline" cssclass="msg" placeholder="message" height="96px" width="130%" font-names="letter gothic std" font-size="15px"></asp:textbox> </td></tr> <tr> <td> <asp:button id="btn_send" runat="server" text="send" cssclass="button1" onclick="btn_send_click" /> </td> </tr> </table> <asp:label id="label1" runat="server" font-bold="true" font-names="letter gothic std" forecolor="#0099ff"></asp:label> </td> </tr> </table> so, how receive messages send user in mymail@gmail.com
ps:this dummy project, possible without hosting website? thank :)
pps: , yes if possible, if able messages in gmail account necessary store data in database through form?
with following code able send email specific user,if want send through front end request, different logic same
using system; using system.collections.generic; using system.linq; using system.net; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace sendemail { public partial class sendemail : system.web.ui.page { protected void page_load(object sender, eventargs e) { sendmail(); } protected void sendmail() { var fromaddress = ""; var toaddress = ""; //password of gmail address const string frompassword = ""; string subject = ""; string body = ""; // smtp settings var smtp = new system.net.mail.smtpclient(); { smtp.host = "smtp.gmail.com""; smtp.port = 587; smtp.enablessl = false; smtp.deliverymethod = system.net.mail.smtpdeliverymethod.network; smtp.credentials = new networkcredential(fromaddress, frompassword); smtp.timeout = 20000; } // passing values smtp object smtp.send(fromaddress, toaddress, subject, body); } } }
Comments
Post a Comment