G
Guest
HI All,
I am encountering the following error when I try to send an email through a
SMTP server. I believe the problem lies with the authentication part when the
network crednetials are used, error is thrown at the .send point.
Error is:
The following error occured Sending an email: System.ApplicationException:
An error occurred sending an email To (e-mail address removed)
From (e-mail address removed) 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)
--
The code looks like:
MailMessage Message = new MailMessage();
string[] AddressList;
AddressList = To.Split(Convert.ToChar(";"));
// To list
for (int i = 0; i <= AddressList.GetUpperBound(0); i++)
{
if (AddressList != string.Empty)
{Message.To.Add(AddressList);}
}
// CC list
AddressList = CC.Split(Convert.ToChar(";"));
for (int i = 0; i <= AddressList.GetUpperBound(0); i++)
{
if (AddressList != string.Empty)
{Message.CC.Add(AddressList);}
}
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);
Big thank you for your help.
I am encountering the following error when I try to send an email through a
SMTP server. I believe the problem lies with the authentication part when the
network crednetials are used, error is thrown at the .send point.
Error is:
The following error occured Sending an email: System.ApplicationException:
An error occurred sending an email To (e-mail address removed)
From (e-mail address removed) 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)
--
The code looks like:
MailMessage Message = new MailMessage();
string[] AddressList;
AddressList = To.Split(Convert.ToChar(";"));
// To list
for (int i = 0; i <= AddressList.GetUpperBound(0); i++)
{
if (AddressList != string.Empty)
{Message.To.Add(AddressList);}
}
// CC list
AddressList = CC.Split(Convert.ToChar(";"));
for (int i = 0; i <= AddressList.GetUpperBound(0); i++)
{
if (AddressList != string.Empty)
{Message.CC.Add(AddressList);}
}
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);
Big thank you for your help.