Guest User

Untitled

a guest
Aug 31st, 2018
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. How do i obtain my smtp host?
  2. <mailSettings>
  3.  
  4. <smtp from="makovetskiyd@yahoo.co.uk">
  5.  
  6. <network host="localhost" port="25" userName="username" password="secret" defaultCredentials="true" />
  7.  
  8. </smtp>
  9.  
  10. </mailSettings>
  11.  
  12. MailMessage message = new MailMessage();
  13.  
  14. message.From = new MailAddress("makovetskiyd@yahoo.co.uk");
  15.  
  16.  
  17.  
  18. message.To.Add(new MailAddress("makovetskiyd@yahoo.co.uk"));
  19.  
  20.  
  21.  
  22.  
  23. message.CC.Add(new MailAddress("makovetskiyd@yahoo.co.uk"));
  24.  
  25. message.Subject = "This is my subject";
  26.  
  27. message.Body = "This is the content";
  28.  
  29.  
  30.  
  31. SmtpClient client = new SmtpClient();
  32.  
  33. client.Send(message);
  34.  
  35. <mailSettings>
  36.  
  37. <smtp from="makovetskiyd@yahoo.co.uk">
  38.  
  39. <network host="smtp.yahoo.com" port="25" userName="username" password="secret" defaultCredentials="true" />// where do i get the host?!? the host prevents me from sending an email
  40.  
  41. </smtp>
  42.  
  43. </mailSettings>
  44.  
  45. using System.Configuration;
  46. using System.Web.Configuration;
  47. using System.Net.Configuration;
  48.  
  49. Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("PathToConfigFile");
  50.  
  51. configurationFile = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath)
  52.  
  53. MailSettingsSectionGroup mailSettings = configurationFile.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
Add Comment
Please, Sign In to add comment