Add-in problem: First email in outbox gets stuck

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..
 
K

Ken Slovak - [MVP - Outlook]

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
 
T

TTT

>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.
 
K

Ken Slovak - [MVP - Outlook]

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.

>
 
T

TTT

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);

}

}
 
T

TTT

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?.
 
K

Ken Slovak - [MVP - Outlook]

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
 
T

TTT

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
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 4
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
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
O Outlook tasks - Add text column with multiple lines Using Outlook 3
W April 2020 Office 365 Update - Add-Ons fail after Office 365 Update Using Outlook 6
Z Task Filter Not Working When I add too many criteria Using Outlook 0
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
P Add Paste Unformatted to QAT Using Outlook 1
M Ignore slow add-ins Using Outlook 0
B Add Prefix text to Subject Line Using Outlook 1
Jennifer Murphy Add birthdays to calendar Using Outlook 7
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4

Similar threads

Top