Is it even possible to send a text control (for user input) inside an email sent using System.Net.Mail (MVC C#)?
I am able to send the action links inside the mail body using html, and depending on the link that they click, it goes to the appropriate controller action. I want to be able to send this
textboxvia email, then add this textbox's value (from the user) to the database?
So I would like to know if it is even possible to do this.
AttitudeMatters
but it only shows the value in the body of the email...
string abc= "<input type = 'text' name = 'tb' value = 'Write here'/>" + "<br/><br/>";
MVC is little different than webforms, on post MVC will bind the name of the input textbox with the model or parameter in the action method, you can use model property or parameter to get the value.
Thank you so much for your prompt reply. But I think I understand the "post" part of it, I have already worked on sending links in the email and then grabbing the parameters in the controller action using their names.
I want the users to see a text control in their email (not the textbox's value). If I write:
string abc= "<input type = 'text'/>"; inside the email body using html,
I am able to see only this ---> [] ---> Just the two square brackets.
Also, there was something strange that I noticed. I can see the textbox in the email sent using
smart phone.
I do not want to provide any button for post. But want to append the textbox's value (user input - basically a string) to a link that is a part of the email. As of now, I am able to append some values to these links (but they are not user input). Also,
I am using string builder in this part of the code to append strings.
Also, the thread that I posted in my previous email, that person has the exact same requirement, and that thread shows that it is almost impossible. That's what I would like to know.
My sincere apologies if I am saying something totally different. I would greatly appreciate further replies to this post. Thank you very much :)
oh, got it, I missunderstood your requirement. Anyway, I believe email do support Html body Content, and you can send it. Email client generally blocks the html and css by default and user has to explicitly enable it to see that.
Make sure you are marking the content as Html in the email class setting.
"Email client generally blocks the html and css by default and user has to explicitly enable it to see that"
My Outlook allows Html and Css, and since I am able to send hyperlinks, I believe that a textbox should also be sent. But I have no idea what's going on here.
"Make sure you are marking the content as Html in the email class setting" - Can you please elaborate more on this one, if it is something other than setting the Mail options inside Outlook?
Thanks so much for your help. Appreciate it! Still waiting for your/somebody else's help to achieve this task. Thank you!!!
Yes, I have already done that. The links and all work just fine. I am able to do all that I want using the anchor tags (controller action and the database tasks). Not sure what's happening with the textbox/textarea though...
Also, I found the following thread, looks like I will have to give up on this :(.
P.S. The only thing that is bothering me is why I can see the textbox/textarea in the email that I see on my phone. I also checked sending it through IE (coz initially I was using Firefox..on local machine).
I would say sending email with Html form is for sure not a good idea, you might want to just send a link in the email and then once user clicks on that they will be redirected to a form where you can collect all the inputs.
AttitudeMatt...
Member
7 Points
33 Posts
Sending a textbox control for user input via email in MVC C#
Dec 19, 2012 12:22 AM|LINK
Hi everyone,
Is it even possible to send a text control (for user input) inside an email sent using System.Net.Mail (MVC C#)?
I am able to send the action links inside the mail body using html, and depending on the link that they click, it goes to the appropriate controller action. I want to be able to send this textbox via email, then add this textbox's value (from the user) to the database?
I searched for it and found this:
http://stackoverflow.com/questions/2697713/how-to-add-textbox-in-the-mail-body
So I would like to know if it is even possible to do this.
Note: I tried the usual textbox like below, but it only shows the value in the body of the email...
string abc= "<input type = 'text' name = 'tb' value = 'Write here'/>" + "<br/><br/>";
Any help/suggestion is very much appreciated. Thanks a lot guys!
CPrakash82
All-Star
18282 Points
2840 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 19, 2012 12:57 AM|LINK
MVC is little different than webforms, on post MVC will bind the name of the input textbox with the model or parameter in the action method, you can use model property or parameter to get the value.
I would suggest to follow some tutorials on this site - www.asp.net/mvc/tutorials
AttitudeMatt...
Member
7 Points
33 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 19, 2012 05:16 PM|LINK
Hi CPrakash82,
Thank you so much for your prompt reply. But I think I understand the "post" part of it, I have already worked on sending links in the email and then grabbing the parameters in the controller action using their names.
I want the users to see a text control in their email (not the textbox's value). If I write:
string abc= "<input type = 'text'/>"; inside the email body using html,
I am able to see only this ---> [] ---> Just the two square brackets.
Also, there was something strange that I noticed. I can see the textbox in the email sent using smart phone.
I do not want to provide any button for post. But want to append the textbox's value (user input - basically a string) to a link that is a part of the email. As of now, I am able to append some values to these links (but they are not user input). Also, I am using string builder in this part of the code to append strings.
Also, the thread that I posted in my previous email, that person has the exact same requirement, and that thread shows that it is almost impossible. That's what I would like to know.
My sincere apologies if I am saying something totally different. I would greatly appreciate further replies to this post. Thank you very much :)
CPrakash82
All-Star
18282 Points
2840 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 19, 2012 08:34 PM|LINK
oh, got it, I missunderstood your requirement. Anyway, I believe email do support Html body Content, and you can send it. Email client generally blocks the html and css by default and user has to explicitly enable it to see that.
Make sure you are marking the content as Html in the email class setting.
AttitudeMatt...
Member
7 Points
33 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 19, 2012 10:59 PM|LINK
"Email client generally blocks the html and css by default and user has to explicitly enable it to see that"
My Outlook allows Html and Css, and since I am able to send hyperlinks, I believe that a textbox should also be sent. But I have no idea what's going on here.
"Make sure you are marking the content as Html in the email class setting" - Can you please elaborate more on this one, if it is something other than setting the Mail options inside Outlook?
Thanks so much for your help. Appreciate it! Still waiting for your/somebody else's help to achieve this task. Thank you!!!
CPrakash82
All-Star
18282 Points
2840 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 20, 2012 12:12 AM|LINK
MailMessage has a property IsBodyHtml, this you need to set as true to send html content.
message.IsBodyHtml = true;
AttitudeMatt...
Member
7 Points
33 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 20, 2012 12:21 AM|LINK
CPrakash82:
Yes, I have already done that. The links and all work just fine. I am able to do all that I want using the anchor tags (controller action and the database tasks). Not sure what's happening with the textbox/textarea though...
Also, I found the following thread, looks like I will have to give up on this :(.
http://social.msdn.microsoft.com/Forums/eu/worddev/thread/244bd2f5-5169-477c-b866-840f276ce5ff
http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/aaf758ab-8de8-4f25-ac40-dc880fe4ef34/
P.S. The only thing that is bothering me is why I can see the textbox/textarea in the email that I see on my phone. I also checked sending it through IE (coz initially I was using Firefox..on local machine).
Thanks a lot!!!
CPrakash82
All-Star
18282 Points
2840 Posts
Re: Sending a textbox control for user input via email in MVC C#
Dec 20, 2012 01:11 AM|LINK
I would say sending email with Html form is for sure not a good idea, you might want to just send a link in the email and then once user clicks on that they will be redirected to a form where you can collect all the inputs.
Some discussion here.