Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void HandlingMail(List<String> destEmails, String subject, String body)
- {
- System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
- foreach (String email in destEmails)
- {
- message.To.Add(email);
- }
- message.From = new System.Net.Mail.MailAddress("unknown@gmail.com");
- message.Subject = subject;
- message.IsBodyHtml = true;
- message.Body = body;
- System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
- smtp.EnableSsl = true;
- smtp.Port = 587;
- smtp.Credentials = new System.Net.NetworkCredential("unknown@gmail.com", "password");
- try
- {
- smtp.Send(message);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.StackTrace);
- Console.WriteLine(ex.Message);
- Console.WriteLine(ex.InnerException);
- }
- finally
- {
- message.Dispose();
- }
- }
- // Here is the error
- //9/23/2015 8:50:53 PM at System.Net.Mail.SmtpClient.Send(MailMessage message)
- // at Program1.MailHandler.HandlingMail(List`1 destEmails, String subject, String body)
- // 9/23/2015 8:50:53 PM Failure sending mail.
- // 9/23/2015 8:50:53 PM System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network [2600:f8m0:4001:d06::9c]:587
- //at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
- //at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
- // --- End of inner exception stack trace ---
- //at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
- //at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback)
- //at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
- //at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
- //at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
- //at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
- //at System.Net.Mail.SmtpClient.GetConnection()
- //at System.Net.Mail.SmtpClient.Send(MailMessage message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement