Add-in problem: First email in outbox gets stuck

  • Thread starter Thread starter TTT
  • Start date Start date
Status
Not open for further replies.
T

TTT

I'm having a problem with an add-in we make. When "Send immediately when connected" is unchecked, the first email sent will sit in Outbox permanently. It has a Date of None and is in bold but not italics.

Any subsequent emails will have a proper datestamp and be in italics and get sent at the appropriate time (so long as the first email is still sitting there blocked).

Why is my add-in causing this? It is only happening in Outlook 2003, 2007 works fine..
 
Are you releasing all references to the item once it's sent and placed by

Outlook in Outbox? Any attempts to touch an item in Outbox will result in

the condition you describe.

You can always force a send by starting a SyncObjects() method call. That

can start the normal send/receive cycle and send the item out, but if you

are messing with it in Outbox it still won't get sent.

"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message

news:OQs8U0kyKHA.5036@TK2MSFTNGP02.phx.gbl...
> I'm having a problem with an add-in we make. When "Send immediately when
> connected" is unchecked, the first email sent will sit in Outbox
> permanently. It has a Date of None and is in bold but not italics.
> Any subsequent emails will have a proper datestamp and be in italics and
> get sent at the appropriate time (so long as the first email is still
> sitting there blocked). Why is my add-in causing this? It is only
> happening in Outlook 2003, 2007 works fine.. Submitted using
> https://forums.slipstick.com
 
>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.
 
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.

>
 
I think this is causing the problem

if (_explorer.Selection[1] is Outlook.MailItem)

{

try

{

foreach (Office.CommandBar bar in _commandBars)

{

if (bar.Name == "Context Menu")

{

// we found the context menu

Office.MsoBarProtection oldProtection = bar.Protection;

bar.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoProtection;

this.AddContextMenuOptions(bar, _explorer.Selection);

bar.Protection = oldProtection;

}

}

}

catch (Exception ex)

{

EmailTRACERManager.Manager.LogError(ex.Message + " " + ex.StackTrace);

}

}
 
It's the if statement

if (_explorer.Selection[1] is Outlook.MailItem)

and in particular, the cast(?) to MailItem. This seems to be changing the Selection item in some way so this behaviour occurs. Is this a bug or some sort of un-named reference that needs to be nulled?.
 
Please leave part of the preceding thread in your posts. I don't know if

that forum sucks and doesn't leave posting quoting, or if you are purposely

deleting that, but it make it very hard to follow a thread.

What folder is the Selection in? If it's Outbox you are causing the problem.

As I said earlier in the thread you should not touch items in Outbox if you

want them to get sent. Even an access to an item will prevent the item from

sending.

"TTT" <alistair[at]timetracer[dot]com[dot]au> wrote in message

news:%23TAkX8vzKHA.4384@TK2MSFTNGP06.phx.gbl...
> It's the if statement

> if (_explorer.Selection[1] is Outlook.MailItem)

> and in particular, the cast(?) to MailItem. This seems to be changing the
> Selection item in some way so this behaviour occurs. Is this a bug or some
> sort of un-named reference that needs to be nulled?. Submitted using
> https://forums.slipstick.com
 
Thanks Ken,

Not doing this section of code for the Outbox avoids this problem. I have a related problem I will post that my not be so simple to fix.

Hope this looks better.

[quote title=kenslovak wrote on Mon, 29 March 2010 09:15]

What folder is the Selection in? If it's Outbox you are causing the problem.

As I said earlier in the thread you should not touch items in Outbox if you

want them to get sent. Even an access to an item will prevent the item from

sending.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Add-in problem: Process All Marked Header doesn't display email bodies Outlook VBA and Custom Forms 5
T Problem with .Recipients.Add("alias") Outlook VBA and Custom Forms 3
C problem of add replicate of ex2k public folder to ex07 Exchange Server Administration 4
B Add-in deployment problem Outlook VBA and Custom Forms 3
P Problem in permanent type add-in toolbar Outlook VBA and Custom Forms 6
K Re: Problem wit deploying Outlook Add-in Outlook VBA and Custom Forms 1
E Problem wit deploying Outlook Add-in Outlook VBA and Custom Forms 3
E Problem with Deploying Add-In Outlook VBA and Custom Forms 1
Y Outlook 2007 add-in installation problem on Vista Outlook VBA and Custom Forms 1
T Add Account Using Outlook 0
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
G Outlook 2021 Add Picture to Custom Contact Form Outlook VBA and Custom Forms 2
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
G automatically choosing "add to autocorrect" option Using Outlook 0
F Want to add second email to Outlook for business use Using Outlook 4
K Add an entry to a specific calendar Using Outlook 1
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
O Add Day Number of the year for 2023-2033 Outlook VBA and Custom Forms 5
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
Witzker Add a text line at the end of the note field in all selected Contacts Outlook VBA and Custom Forms 7
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
N How to add or delete items to Move dropdown Menu Using Outlook 0
G Add contacts birthday to calendar Using Outlook 4
V How to add 'Previous Item' and 'Next Item' to the Quick Access Toolbar Using Outlook 1
Commodore Safe way to add or update holidays; Windows Notifications issue Using Outlook 8
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
L did MS ever add way to text via Outlook Using Outlook 5
P How to add a column named categories when searching in Outlook Using Outlook 0
M add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 5
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
Witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
P Add inanimate objects to meetings? Using Outlook 1
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
BartH Add a string to the conditions in .Conditions.BodyOrSubject.Text Outlook VBA and Custom Forms 2
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
D Do I need Exchange Add-In? Using Outlook 6
C-S-R Manage Add-ins (Remove Wunderlist) Using Outlook 6
A iCloud add in problems Using Outlook 4
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 17
C Looking for feedback on new Outlook Add-in Using Outlook 0
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
S Add VBA save code Using Outlook 0
P Shortcut Pane - add shortcut to Office365 group mailbox Using Outlook 1
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1

Similar threads

Back
Top