473,386 Members | 1,630 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,386 software developers and data experts.

CDO Emails not sent till application is exited

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.

Mar 23 '07 #1
7 1439
On Mar 23, 10:59 am, merzi...@gmail.com wrote:
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?

Mar 23 '07 #2
- 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).Valu e =
CDO.CdoSendUsing.cdoSendUsingPort
Flds(CDO.CdoConfiguration.cdoSMTPServer).Value =
Config.SmtpServer
Flds(CDO.CdoConfiguration.cdoSMTPServerPort).Value = 25
Flds(CDO.CdoConfiguration.cdoSMTPAuthenticate).Val ue =
CDO.CdoProtocolsAuthentication.cdoAnonymous.cdoAno nymous
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?

Mar 23 '07 #3
On 23 Mar 2007 08:31:15 -0700, me******@gmail.com wrote:
iMsg.
Try adding

iMsg.Dispose();

after you send and see if that helps.
--
Bits.Bytes
http://bytes.thinkersroom.com
Mar 23 '07 #4
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.
-----------------------------
<me******@gmail.comwrote in message
news:11*********************@e1g2000hsg.googlegrou ps.com...
>- 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).Valu e =
CDO.CdoSendUsing.cdoSendUsingPort
Flds(CDO.CdoConfiguration.cdoSMTPServer).Value =
Config.SmtpServer
Flds(CDO.CdoConfiguration.cdoSMTPServerPort).Value = 25
Flds(CDO.CdoConfiguration.cdoSMTPAuthenticate).Val ue =
CDO.CdoProtocolsAuthentication.cdoAnonymous.cdoAno nymous
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?

Mar 23 '07 #5
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.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:OI******************************@comcast.com. ..
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.
-----------------------------
<me******@gmail.comwrote in message
news:11*********************@e1g2000hsg.googlegrou ps.com...
>>- 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).Valu e =
CDO.CdoSendUsing.cdoSendUsingPort
Flds(CDO.CdoConfiguration.cdoSMTPServer).Value =
Config.SmtpServer
Flds(CDO.CdoConfiguration.cdoSMTPServerPort).Value = 25
Flds(CDO.CdoConfiguration.cdoSMTPAuthenticate).Val ue =
CDO.CdoProtocolsAuthentication.cdoAnonymous.cdoAn onymous
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?




Mar 23 '07 #6

You need to rewrite your email sending library.

You can get some ideas here.

(1.1 and 2.0 downloadable code)
2/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)
http://sholliday.spaces.live.com/blog/
<me******@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
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.

Mar 23 '07 #7


Frequently Asked Questions for System.Net.Mail

2.0 - http://www.systemnetmail.com/
Frequently Asked Questions for System.Web.Mail

1.1 - http://www.systemwebmail.com/
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.

Mar 24 '07 #8

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

Similar topics

2
by: Joey | last post by:
I am currently developing a C# asp.net application where users are required to register. The application then generates a simple, plain text email and sends it to the new user. I have been...
5
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
0
by: manevski ognjen | last post by:
Hi, I have one problem with console application and threading. In my SMtp class I have method that sends emmails with attachments with html text. Program should work with, let say 10 emails,...
1
by: phpuser123 | last post by:
I have visited various sites n when I log in,there is an option "remember me" I want to know how this works....Do they use a cookie for this task..... I usually put time()+3600 for it to expire...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.