[英]VB.net Suggestions for SMTP client connection error, trying to send message through exchange server
So I'm trying to connect to our exchange server and send a message through vb.net using the smtpClient. 因此,我尝试连接到我们的交换服务器,并使用smtpClient通过vb.net发送消息。 Here is my code:
这是我的代码:
Dim smtp As New SmtpClient("exchangeserver.com")
Dim mail As New MailMessage
mail.From = New MailAddress("me@me.com")
mail.To.Add("me@me.com")
mail.Subject = "Test Email"
mail.Body = "Testing body."
Try
smtp.Send(mail)
Catch exc As Exception
Console.WriteLine(exc.ToString)
End Try
The exception I'm getting indicates that: 我收到的异常表明:
System.Net.Mail.SmtpException: Failure Sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions ##.##.#.##:25
Seems like I can't connect on that port? 好像我无法在该端口上连接? No permissions... should I try something else or revert back to sending emails through outlook?
没有权限...我应该尝试其他方法还是恢复通过Outlook发送电子邮件?
要检查的一件事...您可能需要设置凭据...调查一下
smtp.Credentials = New Net.NetworkCredential( "blah blah blah", "yada yada")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.