List Info

Thread: Windows services SMTP server issue




Windows services SMTP server issue
country flaguser name
United States
2007-02-16 04:17:13
Hi guys and gals, could do with a bit of help here...

I am currently writing a windows service, the basic gist of
it is that
every 5 minutes, it will wake up, query a SQL Server 2005
database and
then send an email to a preconfigured address with the body
being the
query results.

My problem is this: The service runs and when I debug it
everything is
executing fine, there are no errors popping up in the logs
etc and
everything seems as it should be. But!!! The emails are not
being sent
to the SMTP message queue until the service is stopped...
This seems
very strange behavious, is there a way i can flush the
emails so that
they are sent when they are actually created instead of when
the
service is stopped?

thanks

the code that sends the mail is this:

try
            {
                sqlcon.Open();
                SqlDataReader sqlrdr =
comstr.ExecuteReader();
                createNewEmail(sqlrdr, to);
                mailsrv.Send(mail);
                applog.WriteEntry("Mail sent
successfully(theoretically!!) at " +
System.DateTime.Now.ToString()  ,
EventLogEntryType.SuccessAudit);

            }
            catch (Exception ex)
            {
                applog.WriteEntry(ex.Message,
EventLogEntryType.Error);
            }
            finally
            {
                sqlcon.Close();
            }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )