Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-05-13
7
255 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
ID: 24375194
mail.To.Add(new MailAddress(textEmailAdd.Text) );
0
 
LVL 16

Expert Comment

by:Walter Ritzel
ID: 24375227
mail.To = textEmailAdd.Text;
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 24375236
mail.To.Add = new MailAddress(textEmailAdd.Text);
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Closing Comment

by:devnewbee
ID: 31580992
Thanks so much.  I appreciate your help.
0
 

Author Comment

by:devnewbee
ID: 24375247
Thanks to everyone.
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24375273
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 16

Expert Comment

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

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 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