Solved

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

Posted on 2009-05-13
7
253 Views
Last Modified: 2013-11-07
This will not work. ( mail.To.Add = textEmailAdd.Text;)

What am I doing wrong?
MailMessage mail = new MailMessage();

                mail.From = new MailAddress("do-not-reply@test.com");

                mail.To.Add = textEmailAdd.Text;

                mail.Subject = "Test E-Mail";

                mail.Body = html;

                mail.IsBodyHtml = true;

                SmtpClient smtp = new SmtpClient("test.smtp.com");

                smtp.Send(mail);

Open in new window

0
Comment
Question by:devnewbee
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 500 total points
Comment Utility
mail.To.Add(new MailAddress(textEmailAdd.Text) );
0
 
LVL 15

Expert Comment

by:Walter Ritzel
Comment Utility
mail.To = textEmailAdd.Text;
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
mail.To.Add = new MailAddress(textEmailAdd.Text);
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Closing Comment

by:devnewbee
Comment Utility
Thanks so much.  I appreciate your help.
0
 

Author Comment

by:devnewbee
Comment Utility
Thanks to everyone.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
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 ...

cheers!
0
 
LVL 15

Expert Comment

by:Walter Ritzel
Comment Utility
Well,
my mistake is think of on the deprecated System.We.Mail namespace.... I look into an old code of mine...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now