CDO Emails not sent till application is exited

  • Thread starter Thread starter merziyah
  • Start date Start date
M

merziyah

I'm new to posting issues online, so bare with me...
Does anyone have any clues on this:
I have an application that is set to run as a service and it sends an
email if an error is encountered. The emailing part seems to work fine
- no errors, except that the emails don't get sent until the
application/service is exited. As soon as I quite the application, the
emails are sent and arrive in my inbox. I need the emails to be sent
without having to shutdown the application. Any clues? Could I be
missing something? Some object that needs to be destroyed?

I'm using the CDO object to generate emails.
 
I'm new to posting issues online, so bare with me...
Does anyone have any clues on this:
I have an application that is set to run as a service and it sends an
email if an error is encountered. The emailing part seems to work fine
- no errors, except that the emails don't get sent until the
application/service is exited. As soon as I quite the application, the
emails are sent and arrive in my inbox. I need the emails to be sent
without having to shutdown the application. Any clues? Could I be
missing something? Some object that needs to be destroyed?

I'm using the CDO object to generate emails.

Could you please post some of your sending code?
 
- The strToList is an array of email addresses.

Public Shared Sub SendMail_CDO(ByVal strFrom As String, ByVal
strToList() As String, ByVal subject As String, ByVal body As String)
Const Source As String = "Config.SendMail_CDO"
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields

Flds = iConf.Fields
Flds(CDO.CdoConfiguration.cdoSendUsingMethod).Value =
CDO.CdoSendUsing.cdoSendUsingPort
Flds(CDO.CdoConfiguration.cdoSMTPServer).Value =
Config.SmtpServer
Flds(CDO.CdoConfiguration.cdoSMTPServerPort).Value = 25
Flds(CDO.CdoConfiguration.cdoSMTPAuthenticate).Value =
CDO.CdoProtocolsAuthentication.cdoAnonymous.cdoAnonymous
Flds.Update()

Dim strTo As String

Try
For i As Int32 = 0 To strToList.Length - 1
Dim iMsg As New CDO.Message
iMsg.Configuration = iConf
strTo = strToList(i).Trim

iMsg.From = strFrom
iMsg.To = strTo
iMsg.Subject = subject
iMsg.TextBody = body

Trace.WriteTrace("Sending Email to " + strToList(i))
iMsg.Send()
Trace.WriteTrace("Sent Email to " + strToList(i))
Next

Catch ex As Exception

End Try
End Sub

Does this help, or do you you need some more context?
 
Is there any particular reason you're not using CDONTS? Is that old school?
That's what I used in VB6 and it worked like a charm. If you're interested,
post back and I'll post my code.

Robin S.
 
Better yet, is there any reason you're not using the framework's SMTP mail
classes. There is one mail class in the web section and a newer one in the
general system namespace in .NET 2.0. Both these classes use CDO
underneath.

Mike Ober.
 
Back
Top