Italics means the item will be sent (it's submitted to the transport),
non-italics means it won't go out. If it starts italicized and then changes
something is messing with it. Only you could tell what's different that
first time than any other time.
You can use the Locals window to see what objects are in scope and have
values at various places in your code, but as far as making sure of
releasing objects it's more a case of seeing what's declared and making sure
each object hits a release.
One possibility is an exception causing a release line to not be executed.
Another possibility is something that only gets executed in startup,
depending on when you send the first item.
Another possibility I've seen with managed code is when an object is
released by you as opposed to when it's actually released. If you set an
object to null (Nothing in VB.NET) you are releasing your object reference.
However, it's not completely released (RCW destroyed) until sometime later
when the garbage collector runs.
If you need something to be released at a specific or determined time you
can't just wait for the GC to run, although that works fine if you don't
care exactly when the release occurs.
To make something release completely you need to check it for null, then
release it like so:
if (oFoobar != null)
{
Marshal.ReleaseComObject(oFoobar);
GC.Collect();
Marshal.WaitForPendingFinalizers();
GC.Collect();
oFoobar = null;
}
If an object might have more than one reference in its COM refcount you
could need to get the return value of the Marshal.ReleaseComObject()
function and call that method until the return is 0.
Code like that will release your object references completely. However, you
need to use that sort of code sparingly. For one thing it's a performance
hit. For another, the CLR has a habit of treating different objects that
share an RCW as one and releasing all references even if you didn't intend
that.
"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message
news:u$UzmXxyKHA.2436@TK2MSFTNGP04.phx.gbl...
> >Are you releasing all references to the item once it's sent and placed by
> >Outlook in Outbox?
> I think so. Is there a way I can tell at run time?
> I certainly can't see anthing that being executed different the first time
> from the second, and the second time works fine.
> If it's any help, the email flashes up in italics before it is imediately
> changed to non-italics bold.
>