应用程序位于网络

时间:2015-07-13 14:51:00

标签: c# smtp

所以我尝试使用一些标准代码在我的应用中发送电子邮件:

MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "mail.mycompany.es";
client.Credentials = new NetworkCredential("myuser", "somepass");
mail.To.Add(new MailAddress("somemail@gmail.com"));
mail.From = new MailAddress("me@mycompany.es");
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);

它在调试模式下工作,然后我发布它并将.exe放在共享驱动器上。

如果我从那里执行它,它会给我以下例外:

[System.Net.Sockets.SocketException] = {“提供了无效的参数”}

所以它必定是某种权限错误,但我不知道如何解决它。

完全例外转储:

  

System.Net.Mail.SmtpException:Error al enviar correo。

     

---> System.Net.Sockets.SocketException:Se ha proporcionado un argumentonoválido

     

en System.Net.Sockets.Socket..ctor(AddressFamily addressFamily,   SocketType socketType,ProtocolType protocolType)

     

en System.Net.ServicePoint.GetConnection(PooledStream PooledStream,   对象所有者,布尔异步,IPAddress&地址,插座& abortSocket,   插座及放大器; abortSocket6)

     

en System.Net.PooledStream.Activate(Object owningObject,Boolean   async,GeneralAsyncDelegate asyncCallback)

     

en System.Net.PooledStream.Activate(Object owningObject,   GeneralAsyncDelegate asyncCallback)

     

en System.Net.ConnectionPool.GetConnection(Object owningObject,   GeneralAsyncDelegate asyncCallback,Int32 creationTimeout)

     

en System.Net.Mail.SmtpConnection.GetConnection(ServicePoint   服务点)

     

en System.Net.Mail.SmtpTransport.GetConnection(ServicePoint   服务点)

     

en System.Net.Mail.SmtpClient.GetConnection()

     

en System.Net.Mail.SmtpClient.Send(MailMessage message)

     

--- Fin del seguimiento de la pila delaexcepcióninterna---

     

en System.Net.Mail.SmtpClient.Send(MailMessage message)

     

en Isaval.Produccion.AprovisionarViewModel.EnviarSolicitud(Object   obj)en   C:\ Users \用户为myuser \文件\ VS \ Produccion \ Produccion \ AprovisionarViewModel.cs:拉利内阿   36

0 个答案:

没有答案