473,394 Members | 2,052 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,394 software developers and data experts.

repeatedly creating object - bad?

like this:

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset(strSql)
rst.MoveFirst
Do While Not rst.EOF
Set oMailItem = oOutlook.CreateItem(olMailItem)
With oMailItem
.To = rst.Fields("Email1")
.Subject = "test from Access from Mike"
.Body = "don't worry, it's not a virus"
.Send
End With
Set oMailItem = Nothing
rst.MoveNext
Loop

Mike
Nov 12 '05 #1
6 1527
"Mike MacSween" <mi***********************@btinternet.com> wrote in
news:40***********************@news.aaisp.net.uk:
like this:

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset(strSql)
rst.MoveFirst
Do While Not rst.EOF
Set oMailItem = oOutlook.CreateItem(olMailItem)
With oMailItem
.To = rst.Fields("Email1")
.Subject = "test from Access from Mike"
.Body = "don't worry, it's not a virus"
.Send
End With
Set oMailItem = Nothing
rst.MoveNext
Loop


Why set to Nothing when you're immediately going to set it to
something different at the top of the loop? You would then put a Set
to Nothing after the loop terminates.

What's your question?

Oh, I see.

The question is: do you *need* to recreate it or just change the
properties.

Set oMailItem = oOutlook.CreateItem(olMailItem)
Do While Not rst.EOF
With oMailItem
.To = rst.Fields("Email1")
.Subject = "test from Access from Mike"
.Body = "don't worry, it's not a virus"
.Send
End With
rst.MoveNext
Loop
Set oMailItem = Nothing

The answer to the question entirely depends on how Outlook deals
with the message. Does it get a different MessageID? I don't know
what interaction there is between Outlook and Exchange server in
those terms. I also don't know exactly where MessageIDs are
generated (I've always assumed at your local outbound SMTP server).

Of course, if you're generating the same email message to numerous
people, you could use CC or BCC to send a single message to multiple
recipients. Of course, that also may end up getting your email
classified as spam (which, to some people, it may be). Some ISPs
won't accept an email with more than 20 or 25 recipients, so you
might have to break them down in groups.

In any event, I don't know why there's be any reason to recreate the
object -- you could just re-use it. But you'd have to see if there
were any downsides to that.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #2
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.74...
"Mike MacSween" <mi***********************@btinternet.com> wrote in
news:40***********************@news.aaisp.net.uk:
like this:

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset(strSql)
rst.MoveFirst
Do While Not rst.EOF
Set oMailItem = oOutlook.CreateItem(olMailItem)
With oMailItem
.To = rst.Fields("Email1")
.Subject = "test from Access from Mike"
.Body = "don't worry, it's not a virus"
.Send
End With
Set oMailItem = Nothing
rst.MoveNext
Loop
Why set to Nothing when you're immediately going to set it to
something different at the top of the loop? You would then put a Set
to Nothing after the loop terminates.


Thanks David

Yes, you're right I don' need the

Set oMailItem = Nothing
but I do need the
Set oMailItem = oOutlook.CreateItem(olMailItem)
at the top of the loop

Otherwise on the 2nd time through the loop I get

'The Item has been moved or deleted' on the line

To = rst.Fields("Email1")

I'm thinking that the .send makes the mailItem unavailable (which makes
sense) unless it's recreated.
What's your question?

Oh, I see.

The question is: do you *need* to recreate it or just change the
properties.
It seems I need to recreate it. As above. I think I just put a set to
nothing in there to match the createObject above it.
Set oMailItem = oOutlook.CreateItem(olMailItem)
Do While Not rst.EOF
With oMailItem
.To = rst.Fields("Email1")
.Subject = "test from Access from Mike"
.Body = "don't worry, it's not a virus"
.Send
End With
rst.MoveNext
Loop
Set oMailItem = Nothing

The answer to the question entirely depends on how Outlook deals
with the message. Does it get a different MessageID? I don't know
what interaction there is between Outlook and Exchange server in
those terms. I also don't know exactly where MessageIDs are
generated (I've always assumed at your local outbound SMTP server).

Of course, if you're generating the same email message to numerous
people, you could use CC or BCC to send a single message to multiple
recipients.
I'm not. This isn't finished, but inside that loop there'll be another one
preparing the body text for each recipient, which will be different.
Of course, that also may end up getting your email
classified as spam (which, to some people, it may be).
what, 40 emails giving booking details to casually employed staff?
In any event, I don't know why there's be any reason to recreate the
object -- you could just re-use it. But you'd have to see if there
were any downsides to that.


As above.

Cheers, Mike
Nov 12 '05 #3
"Mike MacSween" <mi***********************@btinternet.com> wrote in
news:40***********************@news.aaisp.net.uk:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.74...

Of course, that also may end up getting your email
classified as spam (which, to some people, it may be).


what, 40 emails giving booking details to casually employed staff?


Spam is in the eye of the beholder.

And as more and more people use Bayesian filtering, any email could
get classified as spam, if it is sufficiently similar to the
messages that the recipient has already classified as spam.

If you don't know about Bayesian spam filtering, I suggest you read:

http://www.paulgraham.com/better.html

as well as any number of other fascinating articles on Paul Graham's
website.

I'm using the SAProxy implementation of SpamAssassin, and have been
training the Bayesian filtering since early January (I started off
training it with a body of 10K spam messages and 5K non-spam), and
it's amazingly accurate, with almost no false positives (about 3
since January). Occasionally I get misses, maybe 5 or 10 per week
(out of over 1,000 messages received each week, 90% of which are
spam).

I highly recommend that anyone who is having spam problems
investigate one of the Bayesian solutions, such as SpamBayes or
SAProxy (though the free version is no longer available) or an email
client like Thunderbird that includes built-in Bayesian filtering.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #4
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
Spam is in the eye of the beholder.
I thought it meant Unsolicited Commercial Email.
If you don't know about Bayesian spam filtering, I suggest you read:


Yes, I use the SpamBayes add in for Outlook. It seems pretty good. I'd still
prefer something that added white and black lists. Some of the early false
junk suspects I got were from this client. She wasn't offering to transfer
$30,000,000 (thirty million US dollars) from an account in Lagos, or even
describing in great detail what she wanted to do with parts of my anatomy
(more's the pity!), just something like 'test email' was enough. Still, at
least it went into the Junk suspects folder. Even so it would be nice to
have the facility to always treat email from certain accounts as good.

Personally I'm hoping 'the industry' sorts it out in the next couple of
years.

Mike
Nov 12 '05 #5
"Mike MacSween" <mi***********************@btinternet.com> wrote:
Personally I'm hoping 'the industry' sorts it out in the next couple of
years.


Between Sender Permitted Framework, SPF http://spf.pobox.com/ and MS's CallerID
http://www.microsoft.com/mscorp/twc/privacy/spam.mspx this should help with a great
deal of the spam and virusses.

Both work by telling the recipient email servers which email servers are authorized,
by IP address, to send mail from your domain.

Virusses will now have to go through mail servers to be sent which means that your
ISP or email server can now scan for viruses on outgoing email. And shut you down.

Spams will now have to be associated with domains. Yes, the spammers can purchase
throwaway domains and flood the market. Which they are already doing in the body of
some spams I see.

But no longer will they be able to use "zombies" to send their spams. Zombies being
computers who have been hijacked by virusses and port scans and are being used by the
spammers and hackers.

Thus the efforts of various anti-spam groups can now be targetted towards explicit
domain names and it will be several orders of magnitude easier to deal with the
spammers.

I already have SPF implemented for my domains. Once MS has some testing pages
available I'll be putting those on my domains as well.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #6
"Mike MacSween" <mi***********************@btinternet.com> wrote in
news:40***********************@news.aaisp.net.uk:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
Spam is in the eye of the beholder.
I thought it meant Unsolicited Commercial Email.


It means "email I don't want."

And that's as it should be.
If you don't know about Bayesian spam filtering, I suggest you
read:


Yes, I use the SpamBayes add in for Outlook. It seems pretty good.
I'd still prefer something that added white and black lists. . . .


SpamAssassin has whitelists/blacklists.
. . . Some
of the early false junk suspects I got were from this client. She
wasn't offering to transfer $30,000,000 (thirty million US
dollars) from an account in Lagos, or even describing in great
detail what she wanted to do with parts of my anatomy (more's the
pity!), just something like 'test email' was enough. Still, at
least it went into the Junk suspects folder. Even so it would be
nice to have the facility to always treat email from certain
accounts as good.
In my experience, the single characteristic of an email message most
strongly correlated with spamminess is HTML encoding.
Personally I'm hoping 'the industry' sorts it out in the next
couple of years.


It's already done, so far as I can tell. You just need tools that
present to you all the latest capabilities.

And, of course, you really shouldn't be using Outlook for anything
at all related to email.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #7

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

Similar topics

15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
17
by: Lee Harr | last post by:
I understand how to create a property like this: class RC(object): def _set_pwm(self, v): self._pwm01 = v % 256 def _get_pwm(self): return self._pwm01 pwm01 = property(_get_pwm, _set_pwm)
6
by: wcc | last post by:
Hello, How do I create a class using a variable as the class name? For example, in the code below, I'd like replace the line class TestClass(object): with something like class...
2
by: Moses | last post by:
Hi All, Is is possible to catch the error of an undefined element while creating an object for it. Consider we are not having an element with id indicator but we are trying to make the object...
0
by: shonen | last post by:
Hi guys! Alright so here is my question, I've been messing around with irclib in my python programs creating a bot. I just want to add a little bit of functionality to it! So basically, what...
9
by: =?Utf-8?B?YmJn?= | last post by:
Hi all, I read somewhere "using kernel stuff in thread is not good.." if ManualResetEvent object is created in thread but not actually used, will it affect performance? Bob
10
by: pechar | last post by:
Hi all, I created a test web application in asp.net. It works like a dream in IE but when it gets to Firefox I get an exception as follows ...
5
by: mbewers1 | last post by:
I have a problem with this piece of code, which loads a splash screen and keeps it open for 5 seconds before loading another form. It strangely seems to be repeatedly running a thread once the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.