473,699 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error sending SMTP MAil message in c#

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.Applicat ionException:
An error occurred sending an email To he***@HerMail.c om
From ad*@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.FormatEx ception: Invalid length for a Base-64 char array.
at System.Convert. FromBase64Strin g(String s)
at System.Net.NTAu thentication.Ge tOutgoingBlob(S tring incomingBlob)
at System.Net.Mail .SmtpNtlmAuthen ticationModule. Authenticate(St ring
challenge, NetworkCredenti al credential, Object sessionCookie)
at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
at System.Net.Mail .SmtpClient.Get Connection()
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
--
The code looks like:
MailMessage Message = new MailMessage();
string[] AddressList;
AddressList = To.Split(Conver t.ToChar(";"));
// To list
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.To.Add (AddressList[i]);}
}
// CC list
AddressList = CC.Split(Conver t.ToChar(";"));
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.CC.Add (AddressList[i]);}
}

Message.Subject = Subject;
Message.Subject Encoding = System.Text.Enc oding.UTF8;
Message.From = new
MailAddress(_Fr om,"Finlistener ",System.Text.E ncoding.UTF8);
Message.Body = Body;
Message.BodyEnc oding = System.Text.Enc oding.UTF8;
Message.IsBodyH tml = false;
SmtpClient SMTP = new SmtpClient(_SMT PServer,25);
if (_UserName != string.Empty)
{
SMTP.Credential s = new
System.Net.Netw orkCredential(_ UserName, _Password);
SMTP.DeliveryMe thod = SmtpDeliveryMet hod.Network;
}
SMTP.Send(Messa ge);
Big thank you for your help.
Jul 2 '07 #1
2 12172

"Ade" <ad*@nospam.nos pamwrote in message
news:F4******** *************** ***********@mic rosoft.com...
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.Applicat ionException:
An error occurred sending an email To he***@HerMail.c om
From ad*@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.FormatEx ception: Invalid length for a Base-64 char array.
at System.Convert. FromBase64Strin g(String s)
at System.Net.NTAu thentication.Ge tOutgoingBlob(S tring incomingBlob)
at System.Net.Mail .SmtpNtlmAuthen ticationModule. Authenticate(St ring
challenge, NetworkCredenti al credential, Object sessionCookie)
at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
at System.Net.Mail .SmtpClient.Get Connection()
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
--
The code looks like:
MailMessage Message = new MailMessage();
string[] AddressList;
AddressList = To.Split(Conver t.ToChar(";"));
// To list
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.To.Add (AddressList[i]);}
}
// CC list
AddressList = CC.Split(Conver t.ToChar(";"));
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.CC.Add (AddressList[i]);}
}

Message.Subject = Subject;
Message.Subject Encoding = System.Text.Enc oding.UTF8;
Message.From = new
MailAddress(_Fr om,"Finlistener ",System.Text.E ncoding.UTF8);
Message.Body = Body;
Message.BodyEnc oding = System.Text.Enc oding.UTF8;
Message.IsBodyH tml = false;
SmtpClient SMTP = new SmtpClient(_SMT PServer,25);
if (_UserName != string.Empty)
{
SMTP.Credential s = new
System.Net.Netw orkCredential(_ UserName, _Password);
SMTP.DeliveryMe thod = SmtpDeliveryMet hod.Network;
}
SMTP.Send(Messa ge);
Big thank you for your help.
Obviously, it doesn't like that array in middle of the routine. You need to
pull it out and do that somewhere else and populate it in a string variable
using a stringbuilder or something, having it already populated and ready to
use before you get there.
..

Jul 2 '07 #2
HI Mr Arnold,

Thanks for taking the time to look at my problem. I have re-done the code as
follows, but I get the same error.

MailMessage Message = new MailMessage();
Message.To.Add( new
MailAddress("he ***@HerMail.com ","Helen",Syste m.Text.Encoding .UTF8));
Message.Subject = Subject;
Message.Subject Encoding = System.Text.Enc oding.UTF8;
Message.From = new
MailAddress(_Fr om,"Finlistener ",System.Text.E ncoding.UTF8);
Message.Body = Body;
Message.BodyEnc oding = System.Text.Enc oding.UTF8;
Message.IsBodyH tml = false;
SmtpClient SMTP = new SmtpClient(_SMT PServer,25);
if (_UserName != string.Empty)
{
SMTP.Credential s = new
System.Net.Netw orkCredential(_ UserName, _Password);
SMTP.DeliveryMe thod = SmtpDeliveryMet hod.Network;
}
SMTP.Send(Messa ge);
--

Is this what you meant by your last post?
Big thank you for your help.
"Mr. Arnold" wrote:
>
"Ade" <ad*@nospam.nos pamwrote in message
news:F4******** *************** ***********@mic rosoft.com...
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.Applicat ionException:
An error occurred sending an email To he***@HerMail.c om
From ad*@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.FormatEx ception: Invalid length for a Base-64 char array.
at System.Convert. FromBase64Strin g(String s)
at System.Net.NTAu thentication.Ge tOutgoingBlob(S tring incomingBlob)
at System.Net.Mail .SmtpNtlmAuthen ticationModule. Authenticate(St ring
challenge, NetworkCredenti al credential, Object sessionCookie)
at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
at System.Net.Mail .SmtpClient.Get Connection()
at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
--
The code looks like:
MailMessage Message = new MailMessage();
string[] AddressList;
AddressList = To.Split(Conver t.ToChar(";"));
// To list
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.To.Add (AddressList[i]);}
}
// CC list
AddressList = CC.Split(Conver t.ToChar(";"));
for (int i = 0; i <= AddressList.Get UpperBound(0); i++)
{
if (AddressList[i] != string.Empty)
{Message.CC.Add (AddressList[i]);}
}

Message.Subject = Subject;
Message.Subject Encoding = System.Text.Enc oding.UTF8;
Message.From = new
MailAddress(_Fr om,"Finlistener ",System.Text.E ncoding.UTF8);
Message.Body = Body;
Message.BodyEnc oding = System.Text.Enc oding.UTF8;
Message.IsBodyH tml = false;
SmtpClient SMTP = new SmtpClient(_SMT PServer,25);
if (_UserName != string.Empty)
{
SMTP.Credential s = new
System.Net.Netw orkCredential(_ UserName, _Password);
SMTP.DeliveryMe thod = SmtpDeliveryMet hod.Network;
}
SMTP.Send(Messa ge);
Big thank you for your help.

Obviously, it doesn't like that array in middle of the routine. You need to
pull it out and do that somewhere else and populate it in a string variable
using a stringbuilder or something, having it already populated and ready to
use before you get there.
..

Jul 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2592
by: z f | last post by:
Hi, i'm sending mail from the aspx page on the server. it is running on hosting, so i configure the System.Web.Mail.SmtpMail.SmtpServer property to my mail server. but problem is that sender email is also configurable and since the sender email is not from the SMTP server same host, it is not allows to send. i need to ba able to configure the SMTP Auth to be authenticated to different user from the sender email, but i didn't find...
9
3221
by: B-Dog | last post by:
I've built a small app that sends mail through our ISP's SMTP server but when I try to send through my local exchange server I get CDO error. Does webmail use SMTP or does it strictly rely on CDOmail. I don't want to use the Outlook reference because outlook prompts each time program access it and I have found a way to disable that. Can I use webmail with exchange? Thanks
3
372
by: dgiagio | last post by:
Hi, I'm creating a SMTP application and I would like to hear opinions about error handling. Currently there are two functions that communicate with the remote peer: ssize_t smtp_puts(smtp_stream_t *stream, const char *fmt, ...); ssize_t smtp_gets(smtp_stream_t *stream, char *buf, size_t len); Both of them return the number of written bytes to the stream, or -1 if
14
9131
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my local default SMTP Server and my from address is a valid Yahoo/Hotmail address. I have configures the local SMTP Server to allow the IP Address 127.0.0.1.
11
7714
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running the app, even the first time. The application will be required to be sending out repeated emails, about one every second or two. Must this be done asynchronously? Thank you. -Greg I get the generic error messages;
3
1857
by: Ibrahim. | last post by:
Hello, Im getting the following error when mail is sent from ASP.NET 2.0 website. CDO.Messaging componenet is used for sending mail. " The message was not able to be transmitted to the SMTP server. The forwarding error code is 0x800ccc67. The response from the server is as follows. 421 service not available, closing transmission channel
2
6821
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how to fix this error. I am able to send messages sometimes both other times randomly following error appear EXCEPTION:
6
26373
by: Dave Kelly | last post by:
Sorry for the long post, it is easier to discard information than to have to wait for it to arrive. So here goes: This code worked perfectly when I was an Earthlink customer. Sprint decided not to pardner with Earthlink and create their own IP. Since then everything email has been broke. Sprint/Embarq is the only copper wire DSL provider where I live.
5
4687
by: Don Quijote de Nicaragua | last post by:
Hi, everyone I try to send a simple e-mail witch this Code, but always send me a error messages: "ERROR: Failure sending mail." Thansk You. Don Quijote de Nicaragua. Elder Soto. Dim correo As New System.Net.Mail.MailMessage() correo.From = New System.Net.Mail.MailAddress("MyAco...@turbonett.com.ni")
0
8703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8893
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4389
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.