Links

Display an enum for selection in a ComboBox

string[] names = Enum.GetNames(typeof( the_enum ));
Array values = Enum.GetValues(typeof( the_enum ));
DictionaryEntry[] de = new DictionaryEntry[names.Length];
for(int i=0;i<names.Length;i++)
   de[i] = new DictionaryEntry(values.GetValue(i), names[i]);
cbStates.DataSource		= de;
cbStates.DisplayMember	= "Value";
cbStates.ValueMember	= "Key";

Sending an email through default client

string toEmail = "destinataire@pipo.com"; // separation by a comma ',' for more
string subject = "subjet of the email";
// body, the body
string body = texte.Replace("\r\n", "%0A"); // handles linefeeds
string message = string.Format("mailto:{0}?subject={1}&body={2}", toEmail, subject, body);
Process.Start(message);

You can add more mailto commands :

  • CC - carbon copy
  • BCC - blind carbon copy
 
  net_-_tips_and_tricks.txt · Dernier changement: 2006/09/14 21:16