473,508 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SmtpFailedRecipientException + asp.net 2.0

3 New Member
Hi

I have been having problems with smptclient in asp.net 2.0(C#). I found everytime I put a fake email address or any dodgy ones, it nevers calls SmtpFailedRecipientException in the catch statement. Any ideas why please?

This is my coding:
Expand|Select|Wrap|Line Numbers
  1. try
  2.             {
  3.                 MailAddress fromAddress = new MailAddress(From, Name);
  4.                 //***You can specify the host name or ipaddress of your server
  5.                 //***Default in IIS will be localhost 
  6.                 smtpClient.Host = Host;
  7.                 //***Default port will be 25
  8.                 smtpClient.Port = Port;
  9.                 smtpClient.DeliveryMethod = smtpSec.DeliveryMethod;
  10.                 smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
  11.                 smtpClient.UseDefaultCredentials = smtpSec.Network.DefaultCredentials;
  12.                 smtpClient.EnableSsl = false;
  13.                 //***From address will be given as a MailAddress Object
  14.                 oMsg.From = fromAddress;
  15.                 oMsg.Subject = Subject;
  16.                 //***Body can be Html or text format
  17.                 //***Specify true if it  is html message
  18.                 oMsg.IsBodyHtml = EmailBodyFormat;
  19.                 oMsg.Body = EmailBodyText;
  20.  
  21.  
  22.                //***To address collection of MailAddress
  23.               oMsg.To.Add(UsersEmail);
  24.  
  25.                 //***Send SMTP mail
  26.                 smtpClient.Send(oMsg);
  27.                 oMsg = null;
  28.             }
  29.             catch(SmtpFailedRecipientException sfrex)
  30.             {
  31.                 //***The SMTP Server is refusing to forward the Message
  32.             }
  33.  
Can you tell me what could be done? and any examples of coding for me resolve this issue? I have been trying various approaches for several days but to no avail, it does not go to the catch statement.

Thanks

Newbie
Jun 27 '07 #1
5 2706
Frinavale
9,735 Recognized Expert Moderator Expert
Hi

I have been having problems with smptclient in asp.net 2.0(C#). I found everytime I put a fake email address or any dodgy ones, it nevers calls SmtpFailedRecipientException in the catch statement. Any ideas why please?

This is my coding:

Can you tell me what could be done? and any examples of coding for me resolve this issue? I have been trying various approaches for several days but to no avail, it does not go to the catch statement.

Thanks

Newbie
Hey there!
I think the reason why it never calls the SmtpFailedRecipientException catch statement is because it may be throwing a different type of exception.

From what I understand the SmtpClient could be throwing a general SmtpException. Using this Exception you can determine what went wrong by checking the status...

See MSDN for more on the topic.

Cheers!

-Frinny
Jun 27 '07 #2
MorpheusX
3 New Member
Actually I put all the error exceptions - it nevers picks any of them including the SmtpFailedRecipientException as well.
Expand|Select|Wrap|Line Numbers
  1.   catch(SmtpFailedRecipientException sfrex)
  2.             {
  3.                 //***The SMTP Server is refusing to forward the Message
  4.             }
  5.             catch (System.Net.Mail.SmtpException exSmtp)
  6.             {
  7.                 //***Communication with SMTP Server Failed    
  8.  
  9.             }
  10.             catch (System.Net.Sockets.SocketException exp)
  11.             {
  12.  
  13.             }
  14.             catch (System.ComponentModel.Win32Exception exp)
  15.             {
  16.  
  17.             }
  18.             catch (System.Exception exp)
  19.             {
  20.  
  21.             }
  22.  

Any ideas please..... Would really help me in an immense way.

Thanks Newbie
Jun 27 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Actually I put all the error exceptions - it nevers picks any of them including the SmtpFailedRecipientException as well.


Any ideas please..... Would really help me in an immense way.

Thanks Newbie
The SmtpFailedRecipientException
Represents the exception that is thrown when the SmtpClient is not able to complete a Send or SendAsync operation to a particular recipient.
This means that if your SMTP server sends the email and it is never received (because it is a bogus email address), no exception happens. An exception only happens when the SmtpClient (your code) can't send to the SMTP server. When you send an email to an email address that doesn't exist, every thing's fine...the PostMaster will send you an email back saying that the message wasn't delivered but your message sent perfectly fine!

-Frinny
Jun 27 '07 #4
MorpheusX
3 New Member
I understand now what you said made sense perfectly. But what I was hoping was even if a bogus email address gets sent and recieved perfectly. Is there no way to detect the email is in fact a bogus. Cos I was hoping to trap all the bogus email address or bounced email address to an XML log.

Any ideas? I have tried TCPClient and Socket - but they are not very effective either.

Any help will be immensely appreciated.

Thanks

Newbie.
Jun 28 '07 #5
Frinavale
9,735 Recognized Expert Moderator Expert
I don't know if this will help you.
But check out this thread.

-Frinny
Jun 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
19858
by: Gerhard | last post by:
Hi, I some asp.net beta 2 code that works fine on an XP Pro machine, but on a Windows 2003 Server gets the following error: System.Net.Mail.SmtpFailedRecipientException {"Mailbox unavailable....
6
2084
by: RonL | last post by:
What is the recommended best technique for handling errors/exceptions in ASP.Net. I've read about the following techniques: 1. Try/Catch 2. Page_Error 3. Application_Error in the...
0
2579
by: Smokey Grindle | last post by:
I am using the user creation wizard in asp.net 2.0 and using it to send the user an email message when their account is created, well this works great if the address is a valid mailbox, but when it...
1
5028
by: shapper | last post by:
Hello, I created an ASP.NET 2.0 custom control which includes various TextBoxes, Labels and a button. Basically is a contact form. When the button is pressed the values are sent by email. I...
1
4292
by: vbMark | last post by:
Hello, I am able to make a contact form for my site no problem--it works great. However, I am making a contact form so that customers can reach other members who have registered on my site. ...
8
7265
by: shapper | last post by:
Hello, I am trying to send an email using Asp.Net 2.0. I am getting the following error: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such...
4
10842
by: Fabio Visin | last post by:
Hi! I'm studing SmtpFailedRecipientException to trap errors when I'm sending e-mail. I modified a sample code founded on MSDN so: public static void errorMail() { MailAddress from = new...
3
1461
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I have the following code to send an email and I get this error: . The error is on at last line below. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); ...
0
2694
by: Velvet | last post by:
Our staging server has several web sites that send emails. Most of the sites can send email but one of them is gettting the following message when HTML formatted email is sent. We created a test...
0
7224
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,...
0
7323
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,...
1
7039
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...
0
4706
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...
0
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.