无法使用代理服务器发送电子邮件

时间:2014-06-19 09:25:49

标签: vb.net sockets email proxy

我在工作中遇到问题,试图发送电子邮件。 我想这是因为我们使用了代理服务器,但无论如何我都找不到将代理编程到VB.net中的任何助手?

我一直收到以下错误:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 173.194.66.109:25
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)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at SENpic.Email.butSendEmail_Click(Object sender, EventArgs e) in C:\Users\Graham\Documents\Visual Studio 2010\Projects\Email Project\EmailTest\Email.vb:line 28

以下是代码:

Try
   Dim Smtp_Server As New SmtpClient
   Dim e_mail As New MailMessage()
   Smtp_Server.UseDefaultCredentials = False
   Smtp_Server.Credentials = New Net.NetworkCredential("mymail@gmail.com", "password")
   Smtp_Server.Port = 25 '587
   Smtp_Server.EnableSsl = True
   Smtp_Server.Host = "smtp.gmail.com"
   e_mail = New MailMessage()
   e_mail.From = New MailAddress(txtEmailFrom.Text, "SENpic CSP")
   e_mail.To.Add("fred2000@aol.com")
   e_mail.Subject = txtEmailSubject.Text
   e_mail.IsBodyHtml = False
   e_mail.Body = txtEmailMessage.Text
   Smtp_Server.Send(e_mail)
   MsgBox("Your email has been sent", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "EMail...")    
Catch error_t As Exception
   WriteToLogFile("Email: ", error_t.ToString)
   MsgBox(error_t.ToString)
End Try

非常感谢任何帮助。 谢谢 格雷厄姆

0 个答案:

没有答案