I have the following code, and have a couple of questions about its behavior.

Here is the code that I am using.

SmtpClient client = new SmtpClient(mailServer);

MailAddress to = new MailAddress(reciever);

MailAddress from = new MailAddress(advcommemail);

MailMessage aMessage = new MailMessage(from, to);

Attachment anAttachment = new Attachment(aFileName);

aMessage.IsBodyHtml = true;

aMessage.Body = "Attached is your Advanced Commission statement for " + scanDate.ToShortDateString() + "\n\n\n " + advcommcontact;


//aMessage.Body = emailHTML;





catch (Exception e )



logEntry("Error sending notification email to " + to.Address + " - " + e.Message);



Now this does work so Im not in a real hurry to make any invasive changes, but there are a couple of things that have my pondering making some changes.

First off I cant send any mail that is outside of my domain. For this particular application its not a big deal however I would like to be able to send mail to people outside my domain, and im sure future projects will have this requirement.

Second, it takes a VERY long time for the mail to actually be sent. Its not causing any problems in the code as the Client.Send(aMessage) appears to be a fire and forget type of function. I can force the mail to go out by closing down the application but this is a less than desireable solution. Is there some way that I can force the issue and make the mail go out now, rather than waiting

Any input is greatly appreciated!

Re: .NET Framework Networking and Communication questions with the System.Net.Mail.SmtpClient object.

Alexey Raga

Normally you are able to send emails to any address with SmtpClient. May be it is a limitation of your SMTP server, but not by SmtpClient.

About the delay please take a look at: PostID=164793&SiteID=1