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
- try
- {
- MailAddress fromAddress = new MailAddress(From, Name);
- //***You can specify the host name or ipaddress of your server
- //***Default in IIS will be localhost
- smtpClient.Host = Host;
- //***Default port will be 25
- smtpClient.Port = Port;
- smtpClient.DeliveryMethod = smtpSec.DeliveryMethod;
- smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
- smtpClient.UseDefaultCredentials = smtpSec.Network.DefaultCredentials;
- smtpClient.EnableSsl = false;
- //***From address will be given as a MailAddress Object
- oMsg.From = fromAddress;
- oMsg.Subject = Subject;
- //***Body can be Html or text format
- //***Specify true if it is html message
- oMsg.IsBodyHtml = EmailBodyFormat;
- oMsg.Body = EmailBodyText;
- //***To address collection of MailAddress
- oMsg.To.Add(UsersEmail);
- //***Send SMTP mail
- smtpClient.Send(oMsg);
- oMsg = null;
- }
- catch(SmtpFailedRecipientException sfrex)
- {
- //***The SMTP Server is refusing to forward the Message
- }
Thanks
Newbie