在c#中发送SMTP MAil消息时出错 [英] Error sending SMTP MAil message in c#

查看:123
本文介绍了在c#中发送SMTP MAil消息时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送消息(下面的代码),但是我收到以下错误。如果我删除Netwrok凭据部分,那么我会收到一个错误,通过身份验证的SMTP没有用户名和密码,所以我认为它可能与登录凭据有关,我可能是错的,经常是。任何帮助,将不胜感激。谢谢。

I am attempting to send a message (code below) but I get the following error. If I remove the Netwrok credentials part then i get an error that wouold be expected with authenticated SMTP without username and password, so I think that it may something to do with the logon credentials, I could be wrong and often am. Any help would be appreciated. Thanks.

我收到错误。

发生以下错误发送电子邮件:系统。 ApplicationException:
发送电子邮件时发生错误至helen@HerMail.com
来自ade@MyMail.com Cc主题使用Finlistener#1进行测试。正文是:
这是对错误邮件正文的测试--->
System.Net.Mail.SmtpException:发送邮件失败。 --->
System.FormatException:Base-64 char数组的长度无效。在System.Net.N.utTutb的System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)的System.Convert.FromBase64String(String s)

System.Net.Mail的System.Net.Mail.SmtpConnection.GetConnection(String host,Int32 port)上的.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String
challenge,NetworkCredential credential,Object sessionCookie)
System.Net.Mail.SmtpClient.Send(MailMessage消息)上的.smtpTransport.GetConnection(String host,Int32 port)
System.Net.Mail.SmtpClient.GetConnection()

The following error occured Sending an email: System.ApplicationException:
An error occurred sending an email To helen@HerMail.com
From ade@MyMail.com Cc  Subject A test with Finlistener #1. The body was:
This is test for the body of the error email --->
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)

从此代码

MailMessage Message = new MailMessage();
Message.To.Add(new
MailAddress(" helen@HerMail.com","海伦",System.Text.Encoding.UTF8));
Message.Subject = Subject;
Message.SubjectEncoding = System.Text.Encoding.UTF8;
Message.From = new
MailAddress(_From," Finlistener",System.Text.Encoding。 UTF8);
Message.Body = Body;
Message.BodyEncoding = System.Text.Encoding.UTF8;
Message.IsBodyHtml = false;
SmtpClient SMTP = new SmtpClient(_SMTPServer,25);
if(_UserName!= string.Empty)
{
SMTP.Credentials = new
System.Net.NetworkCredential(_UserName,_Password);
SMTP.DeliveryMethod = SmtpDeliveryMethod.Network; < br>}
SMTP.Send(消息);


From this code

MailMessage Message = new MailMessage();
            Message.To.Add(new
MailAddress("helen@HerMail.com","Helen",System.Text.Encoding.UTF8));  
            Message.Subject =  Subject;
            Message.SubjectEncoding = System.Text.Encoding.UTF8;
            Message.From = new
MailAddress(_From,"Finlistener",System.Text.Encoding.UTF8);
            Message.Body = Body;
            Message.BodyEncoding = System.Text.Encoding.UTF8;
            Message.IsBodyHtml = false;
            SmtpClient SMTP = new SmtpClient(_SMTPServer, 25);
            if (_UserName != string.Empty)
            {
                SMTP.Credentials =  new
System.Net.NetworkCredential(_UserName, _Password);
                SMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
            }
            SMTP.Send(Message);
--

推荐答案

已删除


这篇关于在c#中发送SMTP MAil消息时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆