Click here to Skip to main content
11,413,676 members (76,202 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.5
i want to send mail to various pepole listed in a textbox, when a button gets clicked in window application built in c# OMG | :OMG:
Posted 12-Jan-10 1:41am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

protected void sendEmail(string address, string subject, string from, string body)
    {
        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
        message.To.Add(address);
        message.Subject = subject;
        message.From = new System.Net.Mail.MailAddress(from);
        message.Body = body;
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
        smtp.Credentials = new System.Net.NetworkCredential("host", "password");
        smtp.Port = 587;
        smtp.Send(message);
    
    }
  Permalink  
v2
Comments
RaviRanjankr at 25-Jan-11 23:27pm
   
Code is wrapped in "pre" tag to make it readability
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

There are several articles on CodeProject that show you how to send email programatically. The rest of what you're asking is simply setting the listbox as a multi-select ListBox and iterating through the ListBox.SelectedItems collection to get the names (or email addresses, or items, whatever).
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

i don't understand
<pre lang="xml">// Create the email
System.Net.Mail.MailMessage mail = new MailMessage();
mail.To = &quot;to@there.com&quot;;
mail.From = &quot;from@here.com&quot;;
mail.Subject = &quot;subject&quot;;
mail.Body = &quot;the body&quot;;
&lt;strike&gt;// Send the email
SmtpMail.SmtpServer = &quot;your smtp server details&quot;;
SmtpMail.Send(mail);&lt;/strike&gt;
//Scrub that bit above, you should use system.net.mail instead.
// Send the email.
SmtpClient client = new SmtpClient(&quot;your smtp server address&quot;, portnumber);
client.Send(mail);</pre>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

<>&<a href=""></a><a href=""></a>[<a href="" target="_blank"></a>]<big><small></small></big>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to do something like this:

// Create the email
System.Net.Mail.MailMessage mail = new MailMessage();
mail.To = "to@there.com";
mail.From = "from@here.com";
mail.Subject = "subject";
mail.Body = "the body";
 
// Send the email
SmtpMail.SmtpServer = "your smtp server details";
SmtpMail.Send(mail);
//Scrub that bit above, you should use system.net.mail instead.

// Send the email.
SmtpClient client = new SmtpClient("your smtp server address", portnumber);
client.Send(mail);
  Permalink  
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 379
1 Maciej Los 210
2 Sascha Lefévre 175
3 Kornfeld Eliyahu Peter 170
4 KARTHIK Bangalore 145
0 Sergey Alexandrovich Kryukov 9,035
1 OriginalGriff 7,387
2 Maciej Los 3,640
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web03 | 2.8.150427.2 | Last Updated 23 Apr 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100