我用c#2.0写了一个邮件发送小程序,
在使用本地IIS服务设置是没有问题的,可以发送。
可是使用外网却不可以进行发送邮件,
我用我其他人用Delphi进行外网SMTP服务器测试是可以的,
这就说明还是我原程序中出现了问题,请问是什么原因?
代码如下:
mail = new MailMessage();
mailAddress = new MailAddress(sSender, sSenderName);
mail.From = mailAddress;
mail.Subject = sSubject;
mail.Body = sContent; //创建SmtpClient
SmtpClient SmtpMail = new SmtpClient(sSmtpServer, iPort);
SmtpMail.Credentials = new NetworkCredential(sUserName, sPassword);
SmtpMail.Send(mail);sSender,sSenderName,sSmtpServer,iPort,sUserName,sPassword
各参数都没有问题,因为我用同样的参数用Delphi程序测试可以发送,用C#上面的代码测试总是出现“Failure sending mail.”的错误
请大家帮忙解决!
在使用本地IIS服务设置是没有问题的,可以发送。
可是使用外网却不可以进行发送邮件,
我用我其他人用Delphi进行外网SMTP服务器测试是可以的,
这就说明还是我原程序中出现了问题,请问是什么原因?
代码如下:
mail = new MailMessage();
mailAddress = new MailAddress(sSender, sSenderName);
mail.From = mailAddress;
mail.Subject = sSubject;
mail.Body = sContent; //创建SmtpClient
SmtpClient SmtpMail = new SmtpClient(sSmtpServer, iPort);
SmtpMail.Credentials = new NetworkCredential(sUserName, sPassword);
SmtpMail.Send(mail);sSender,sSenderName,sSmtpServer,iPort,sUserName,sPassword
各参数都没有问题,因为我用同样的参数用Delphi程序测试可以发送,用C#上面的代码测试总是出现“Failure sending mail.”的错误
请大家帮忙解决!
解决方案 »
- (1.0).ToString() = "1"???
- 如何改变Gridview中某一列的所有值
- 分来了,这代码有编译错误,其实我想要的是点击button2按钮没有异常
- 通过窗口的句柄如何对窗口的按钮进行操作?
- COM+ Admin类管理远程COM+应用程序的问题
- 苦求关于的无模式对话框问题!!牛人帮忙~~~~
- 高手请近,怎样监视一个进程对硬盘的读写
- c#一连接数据库就出错
- 微软发布“Visual Studio.Net”更新计划
- 熟悉Remoting技术的请进
- 怎样吃掉输入到RichTextBox的某个字符。
- 在vs.net下伪造源页面是不是这样写的? HttpWebRequest HWR = null;HWR.Referer = @"http://club.gzxxx.cn/";
我用try捕捉异常为以下信息:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.FormatException: Invalid length for a Base-64 char array.
at System.Convert.FromBase64String(String s)
at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
at System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
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 Test.MainForm.InnerExceptions() in c:\Documents and Settings\Administrator\My Documents\SharpDevelop Projects\Test\MainForm.cs:line 93System.FormatException: Invalid length for a Base-64 char array.
at System.Convert.FromBase64String(String s)
at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
at System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
http://www.systemnetmail.com/
//使用IIS发送邮件
SmtpMail.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;