473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SmtpFailedRecipientException/s - how it works?

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 MailAddress("fa*********@xxx.it");
MailAddress to = new MailAddress("we*******@xxx.it");
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail message from
an application very easily.";
SmtpClient client = new SmtpClient("smtp.xxx.it");
// Include credentials if the server requires them.
client.Credentials =
(ICredentialsByHost)CredentialCache.DefaultNetwork Credentials;
Console.WriteLine("Sending an e-mail message to {0} using the SMTP host
{1}.", to.Address, client.Host);

try
{
client.Send(message);
}
catch (SmtpFailedRecipientException ex) {
Console.WriteLine("Failed to deliver message to {0}",
ex.FailedRecipient);
//send e-mail back
MailMessage messageError = new MailMessage(from, from);
messageError.Subject = "Error - " + message.Subject;
messageError.Body = ex.Message;
client.Send(messageError);
}
}
I don't understand why it doesn't work well!
If I send an e-mail to a unavailable mailbox inside my smtp client there is
the SmtpFailedRecipientException and it works fine but if I try to an
external unavailable mailbox I don't receive any exception. Where I make the
mistake? how can I solve it?

thanks
Fabio Visin
Apr 11 '07 #1
4 10837
Hi Fabio,

From your description, you're using the .NET 2.0 SmtpClient class to send
email and found that you'll get exception if you send mail to an invalid
address in local network, but didn't get any error when send to an external
invalid address ,correct?

As for this problem, I think the error you got when sending to local
invalid recipient is due to the SMTP server's validation. Are you sending
through a network SMTP server(such as Exchange server)? The SMTP server in
local environent may valid the recipient address immediately(if it is a
local address) and raise error if it is invalid. For external email
address, since the SMTP request will be foward to external intermediate
node, the local SMTP server may not validate it at the exact time,
therefore, your SMTP client does not receive such error information.
Actually, for those mail client such as outlook, when sending it the mail
,it will not validate external mail address immediately. It is later after
the external node send back error message will it popup message sending
fail error. The SmtpClient component will close the communcation with
server right after the message has been sent out, but not trace the
sequentital message delivery status.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 12 '07 #2
Hi Steven,
thanks for the reply, your analysis is completely correct.
Reading your explanation I don't understand the real use of this exception
if I can't get the correct information. Is there the possibility, with a
different approach too, to trace the sequential message delivery status?
I have to check the validity of many e-mail address stored in my DB but I
can't do it manually, there are too much! ;)

Thanks
Fabio
Apr 12 '07 #3
Nobody can help me?
Thanks
Fabio
"Fabio Visin" <fa*********@community.nospamha scritto nel messaggio
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi Steven,
thanks for the reply, your analysis is completely correct.
Reading your explanation I don't understand the real use of this exception
if I can't get the correct information. Is there the possibility, with a
different approach too, to trace the sequential message delivery status?
I have to check the validity of many e-mail address stored in my DB but I
can't do it manually, there are too much! ;)

Thanks
Fabio

Apr 17 '07 #4
Hi Fabio,

After some further research, I found that this should be done through the
smtp server's setting. For example, if your local smtp server is a network
exchange server, the exchange server contains storage for each local
users(on the server) and there you can query the failture messages for each
given user. For other smtp server, it may have different setting or
interface.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 18 '07 #5

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

Similar topics

1
by: Gerd Güldenast | last post by:
Hi, I am having a problem with a replication over a Modem-Connection, which works fine over LAN. Has anyone experienced this problem before? Settings are: 2 SQL Servers 2000, SP3 on Windows...
10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
1
by: Moi | last post by:
I have tried repeatedly to import a MS Works database (simple address database) into Access, but I am having little luck. I have saved the Works file as DbaseIII DbaseIV and neither is seen by the...
2
by: Enrique Bustamante | last post by:
Casting arrays that works on watch and command window but not in code. My application is casting arrays in a way it should work. To test if I was doing something invalid, I wrote a test code that...
4
by: puja | last post by:
hi all, I have an asp.net website where am including .css file dynamically on page load event. For diff users, there is diff CSS file. So after user logs in, I am setting CSS href on page load....
0
by: patmg | last post by:
Hello, We use a SQL Server database to manage accounts in AD via a COM object using ADSI written in VB6. I have to move this database to a new server. The only real difference between the two...
3
by: Miro | last post by:
First off...thanks in advance for getting me this far. Sorry for all these class posts but im having a heck of a time here trying to get something to work, and have finally got it to work (...
5
by: MorpheusX | last post by:
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...
0
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.