Connecting Tech Pros Worldwide Help | Site Map

repeatedly creating object - bad?

  #1  
Old November 12th, 2005, 09:25 PM
Mike MacSween
Guest
 
Posts: n/a
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


  #2  
Old November 12th, 2005, 09:25 PM
David W. Fenton
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"Mike MacSween" <mike.macsween.damnthespam@btinternet.com> wrote in
news:404a6021$0$63622$5a6aecb4@news.aaisp.net.uk:
[color=blue]
> 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[/color]

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
  #3  
Old November 12th, 2005, 09:25 PM
Mike MacSween
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
news:Xns94A4C282E113Ddfentonbwaynetinvali@24.168.1 28.74...[color=blue]
> "Mike MacSween" <mike.macsween.damnthespam@btinternet.com> wrote in
> news:404a6021$0$63622$5a6aecb4@news.aaisp.net.uk:
>[color=green]
> > 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[/color]
>
> 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.[/color]

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.
[color=blue]
> What's your question?
>
> Oh, I see.
>
> The question is: do you *need* to recreate it or just change the
> properties.[/color]

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.
[color=blue]
> 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.[/color]

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.
[color=blue]
> Of course, that also may end up getting your email
> classified as spam (which, to some people, it may be).[/color]

what, 40 emails giving booking details to casually employed staff?
[color=blue]
> 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.[/color]

As above.

Cheers, Mike


  #4  
Old November 12th, 2005, 09:26 PM
David W. Fenton
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"Mike MacSween" <mike.macsween.damnthespam@btinternet.com> wrote in
news:404ab242$0$63621$5a6aecb4@news.aaisp.net.uk:
[color=blue]
> "David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
> news:Xns94A4C282E113Ddfentonbwaynetinvali@24.168.1 28.74...[/color]
[color=blue][color=green]
>> Of course, that also may end up getting your email
>> classified as spam (which, to some people, it may be).[/color]
>
> what, 40 emails giving booking details to casually employed staff?[/color]

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
  #5  
Old November 12th, 2005, 09:26 PM
Mike MacSween
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
[color=blue]
> Spam is in the eye of the beholder.[/color]

I thought it meant Unsolicited Commercial Email.
[color=blue]
> If you don't know about Bayesian spam filtering, I suggest you read:[/color]

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


  #6  
Old November 12th, 2005, 09:26 PM
Tony Toews
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"Mike MacSween" <mike.macsween.damnthespam@btinternet.com> wrote:
[color=blue]
>Personally I'm hoping 'the industry' sorts it out in the next couple of
>years.[/color]

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
  #7  
Old November 12th, 2005, 09:26 PM
David W. Fenton
Guest
 
Posts: n/a

re: repeatedly creating object - bad?


"Mike MacSween" <mike.macsween.damnthespam@btinternet.com> wrote in
news:404b8fa2$0$63626$5a6aecb4@news.aaisp.net.uk:
[color=blue]
> "David W. Fenton" <dXXXfenton@bway.net.invalid> wrote in message
>[color=green]
>> Spam is in the eye of the beholder.[/color]
>
> I thought it meant Unsolicited Commercial Email.[/color]

It means "email I don't want."

And that's as it should be.
[color=blue][color=green]
>> If you don't know about Bayesian spam filtering, I suggest you
>> read:[/color]
>
> Yes, I use the SpamBayes add in for Outlook. It seems pretty good.
> I'd still prefer something that added white and black lists. . . .[/color]

SpamAssassin has whitelists/blacklists.
[color=blue]
> . . . 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.[/color]

In my experience, the single characteristic of an email message most
strongly correlated with spamminess is HTML encoding.
[color=blue]
> Personally I'm hoping 'the industry' sorts it out in the next
> couple of years.[/color]

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
setTimeout and an object's methods Andrew Poulos answers 12 March 13th, 2006 11:55 PM
When to set object references = nothing Mike Eaton answers 12 November 20th, 2005 11:46 PM
Which is advisable for object creation? Balaji Kannan answers 3 November 18th, 2005 02:07 AM
is dynamically creating a new field on a page DHTML, Javascript, XML or a combination? NotGiven answers 6 July 23rd, 2005 02:46 PM
Destroying and creating an object Bushido Hacks answers 17 July 23rd, 2005 04:57 AM