How can I make the value of my "mailaddress to" the value of a textbox?

This will not work. ( mail.To.Add = textEmailAdd.Text;)

What am I doing wrong?
MailMessage mail = new MailMessage();
                mail.From = new MailAddress("");
                mail.To.Add = textEmailAdd.Text;
                mail.Subject = "Test E-Mail";
                mail.Body = html;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient("");

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mail.To.Add(new MailAddress(textEmailAdd.Text) );

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Walter RitzelSenior Software EngineerCommented:
mail.To = textEmailAdd.Text;
Jamie McAllister MVPSharePoint ConsultantCommented:
mail.To.Add = new MailAddress(textEmailAdd.Text);
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

devnewbeeAuthor Commented:
Thanks so much.  I appreciate your help.
devnewbeeAuthor Commented:
Thanks to everyone.
sorry wp and Jaime... but for future if anyone asks this, the Add option of the MailMessage object is a function... so you have to call it as such, and it takes a MailAddress var ...

Walter RitzelSenior Software EngineerCommented:
my mistake is think of on the deprecated System.We.Mail namespace.... I look into an old code of mine...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.