sending mail

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 2
Reputation: sijothomas is an unknown quantity at this point 
Solved Threads: 0
sijothomas sijothomas is offline Offline
Newbie Poster

sending mail

 
0
  #1
Oct 7th, 2009
hi,
I'm new to software developing.....c#.
i am doing a project in c#.I have tried a code to send an email from my software.but i didn't find any sources...Please help me..
Also,Please help me to open a web browser from my project...
Anyway, Thanks for advance..
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast
 
0
  #2
Oct 7th, 2009
Use the SmtpClient and MailMessage classes:
  1. public static SmtpClient GetSmtpClient()
  2. {
  3. SmtpClient smtp = new SmtpClient("smtp.server.com");
  4. if (WebConfigurationVariables.SMTPUseAuth)
  5. {
  6. smtp.Credentials = new NetworkCredential("username", "password");
  7. }
  8. return smtp;
  9. }
  10.  
  11. protected void ButtonSubmit_Click(object sender, EventArgs e)
  12. {
  13. if (IsValid)
  14. {
  15. List<string> Sql = new List<string>();
  16. Sql.Add("Message:");
  17. Sql.Add(TextBoxMessage.Text);
  18.  
  19. try
  20. {
  21. SmtpClient smtp = GetSmtpClient();
  22. using (MailMessage msg = new MailMessage())
  23. {
  24. msg.From = new MailAddress("feedback@______.com", "Online Feedback");
  25. msg.Sender = new MailAddress("feedback@______.com", "Online Feedback");
  26. msg.To.Add(new MailAddress(WebConfigurationVariables.FeedbackEmail));
  27. msg.Subject = "Feedback from www.______.com";
  28. msg.Body = "your message body here";
  29. msg.IsBodyHtml = false;
  30. msg.ReplyTo = new MailAddress("noreply@______", "No Reply");
  31. smtp.Send(msg);
  32. }
  33. }
  34. catch (Exception ex)
  35. {
  36. Log.Exception(ex, Request);
  37. }
  38. }
  39. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC