Guest User

Untitled

a guest
Sep 10th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. Mailbox unavailable. The server response was: No such domain at this location
  2. System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
  3.  
  4. msg.to.add("someone@hotmail.com");
  5. msg.to.add("someone@gmail.com");
  6. msg.to.add("someone@myDomain.com");
  7.  
  8. msg.From = new MailAddress("me@myDomain.com", "myDomain", System.Text.Encoding.UTF8);
  9. msg.Subject = "subject";
  10. msg.SubjectEncoding = System.Text.Encoding.UTF8;
  11. msg.Body = "body";
  12. msg.BodyEncoding = System.Text.Encoding.UTF8;
  13. msg.IsBodyHtml = false;
  14.  
  15. //Add the Creddentials
  16. SmtpClient client = new SmtpClient();
  17. client.Host = "192.168.0.24";
  18. client.Credentials = new System.Net.NetworkCredential("me@myDomain.com", "password");
  19. client.Port = 25;
  20.  
  21. try
  22. {
  23. client.Send(msg);
  24. }
  25. catch (System.Net.Mail.SmtpException ex)
  26. {
  27. sw.WriteLine(string.Format("ERROR MAIL: {0}. Inner exception: {1}", ex.Message, ex.InnerException.Message));
  28. }
  29.  
  30. using System;
  31. using System.Windows.Forms;
  32. using System.Net.Mail;
  33.  
  34. namespace WindowsApplication1
  35. {
  36. public partial class Form1 : Form
  37. {
  38. public Form1()
  39. {
  40. InitializeComponent();
  41. }
  42.  
  43. private void button1_Click(object sender, EventArgs e)
  44. {
  45. try
  46. {
  47. MailMessage mail = new MailMessage();
  48. SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  49.  
  50. mail.From = new MailAddress("your_email_address@gmail.com");
  51. mail.To.Add("to_address@mfc.ae");
  52. mail.Subject = "Test Mail";
  53. mail.Body = "This is for testing SMTP mail from GMAIL";
  54.  
  55. SmtpServer.Port = 587;
  56. SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
  57. SmtpServer.EnableSsl = true;
  58.  
  59. SmtpServer.Send(mail);
  60. MessageBox.Show("mail Send");
  61. }
  62. catch (Exception ex)
  63. {
  64. MessageBox.Show(ex.ToString());
  65. }
  66. }
  67. }
  68. }
Add Comment
Please, Sign In to add comment