Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: New mail event doesn't work all time

Geek News

New mail event doesn't work all time
DavidE 2/1/2007 11:49:00 AM
Hi,

I created a com add-in that fires an event when a new mail arrives. This is
the code:
Private WithEvents objNS As Outlook.NameSpace
Private WithEvents colItems As Outlook.Items

Private Sub Application_Startup()
Set objNS = Application.GetNamespace("MAPI") 'NameSpace Object
Set colItems = objNS.GetDefaultFolder(olFolderInbox).Items
....
End Sub

Private Sub colItems_ItemAdd(ByVal Item As Object)
Code to handle incoming mail
End Sub

Usually, this code does the work but some times it doesn't. When it stop
working the event doesn't fire for all incoming mails. I fix it by closing
and reopen the outlook. When the outlook is reopen it loads the add-in.Some
times I need to restart the computer. I tried to solve this problem by
cretaing a schedule task for a bat file that contain a regsvr32 command for
this dll but it doesn't solve the problem. I don't think that it's a problem
of code but I think that it's a problem of the outlook that unload the add-in
without a logical reason.

I'll glad to get help for this problem.

Thanks,

David
Re: New mail event doesn't work all time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/1/2007 3:05:45 PM
ItemAdd will fail to fire if 16 or more items are added to the Inbox at a
time. That's a hard limitation from MAPI. Your code may be disabled if you
have errors and aren't trapping or handling them.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
news:508FA173-F4CD-4BC7-9D77-33FDC38C9343[ at ]microsoft.com...
[Quoted Text]
> Hi,
>
> I created a com add-in that fires an event when a new mail arrives. This
> is
> the code:
> Private WithEvents objNS As Outlook.NameSpace
> Private WithEvents colItems As Outlook.Items
>
> Private Sub Application_Startup()
> Set objNS = Application.GetNamespace("MAPI") 'NameSpace Object
> Set colItems = objNS.GetDefaultFolder(olFolderInbox).Items
> ....
> End Sub
>
> Private Sub colItems_ItemAdd(ByVal Item As Object)
> Code to handle incoming mail
> End Sub
>
> Usually, this code does the work but some times it doesn't. When it stop
> working the event doesn't fire for all incoming mails. I fix it by closing
> and reopen the outlook. When the outlook is reopen it loads the
> add-in.Some
> times I need to restart the computer. I tried to solve this problem by
> cretaing a schedule task for a bat file that contain a regsvr32 command
> for
> this dll but it doesn't solve the problem. I don't think that it's a
> problem
> of code but I think that it's a problem of the outlook that unload the
> add-in
> without a logical reason.
>
> I'll glad to get help for this problem.
>
> Thanks,
>
> David

Re: New mail event doesn't work all time
DavidE 2/4/2007 10:06:00 AM
Hi Ken,
Thanks for your reply.

I don't think that those are the cases because I never get 16 mails at once
and I don't see any error messeges when the ItemAdd fails, which I should see
if an unhandled error occur.

Let me know if there other reasons for this problem.

David

"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> ItemAdd will fail to fire if 16 or more items are added to the Inbox at a
> time. That's a hard limitation from MAPI. Your code may be disabled if you
> have errors and aren't trapping or handling them.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
> news:508FA173-F4CD-4BC7-9D77-33FDC38C9343[ at ]microsoft.com...
> > Hi,
> >
> > I created a com add-in that fires an event when a new mail arrives. This
> > is
> > the code:
> > Private WithEvents objNS As Outlook.NameSpace
> > Private WithEvents colItems As Outlook.Items
> >
> > Private Sub Application_Startup()
> > Set objNS = Application.GetNamespace("MAPI") 'NameSpace Object
> > Set colItems = objNS.GetDefaultFolder(olFolderInbox).Items
> > ....
> > End Sub
> >
> > Private Sub colItems_ItemAdd(ByVal Item As Object)
> > Code to handle incoming mail
> > End Sub
> >
> > Usually, this code does the work but some times it doesn't. When it stop
> > working the event doesn't fire for all incoming mails. I fix it by closing
> > and reopen the outlook. When the outlook is reopen it loads the
> > add-in.Some
> > times I need to restart the computer. I tried to solve this problem by
> > cretaing a schedule task for a bat file that contain a regsvr32 command
> > for
> > this dll but it doesn't solve the problem. I don't think that it's a
> > problem
> > of code but I think that it's a problem of the outlook that unload the
> > add-in
> > without a logical reason.
> >
> > I'll glad to get help for this problem.
> >
> > Thanks,
> >
> > David
>
>
Re: New mail event doesn't work all time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/4/2007 5:18:36 PM
Is this a COM addin, or Outlook VBA macro code? We're talking about 2
different things.

The code looks like Outlook VBA code, especially with the
Application_Startup() initialization.

You might not see an error message, depending on what level the error
occurred at. It would serve to disable your macro code though. Are you
assuming everything that comes in is a mail item? It might be a meeting
request, task request, etc.

In general, if VBA code works in most situations but gets disabled from time
to time it's a matter of error handling or logic errors.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
news:F29DF476-21FB-4115-8C51-AE361DC2C830[ at ]microsoft.com...
[Quoted Text]
> Hi Ken,
> Thanks for your reply.
>
> I don't think that those are the cases because I never get 16 mails at
> once
> and I don't see any error messeges when the ItemAdd fails, which I should
> see
> if an unhandled error occur.
>
> Let me know if there other reasons for this problem.
>
> David

Re: New mail event doesn't work all time
DavidE 2/5/2007 7:51:00 AM
Hi Ken,

This is a COM AddIn. I create it with VB6.I have a deafult template of
outlook project on it and then I use the dll to install it on users machines.
I check everything that come if it's "IPM.Note"
FormDescription.MessageClass. If it is the code is process.

Is there anything else to check in addition to check the logic again ?

Thanks
David

"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> Is this a COM addin, or Outlook VBA macro code? We're talking about 2
> different things.
>
> The code looks like Outlook VBA code, especially with the
> Application_Startup() initialization.
>
> You might not see an error message, depending on what level the error
> occurred at. It would serve to disable your macro code though. Are you
> assuming everything that comes in is a mail item? It might be a meeting
> request, task request, etc.
>
> In general, if VBA code works in most situations but gets disabled from time
> to time it's a matter of error handling or logic errors.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
> news:F29DF476-21FB-4115-8C51-AE361DC2C830[ at ]microsoft.com...
> > Hi Ken,
> > Thanks for your reply.
> >
> > I don't think that those are the cases because I never get 16 mails at
> > once
> > and I don't see any error messeges when the ItemAdd fails, which I should
> > see
> > if an unhandled error occur.
> >
> > Let me know if there other reasons for this problem.
> >
> > David
>
>
Re: New mail event doesn't work all time
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 2/5/2007 3:12:51 PM
If this is a COM addin why are you using the Application_Startup()
procedure? In many or most cases it will fire before your addin is started
by Outlook. You would want to use either the On_Connection event handler or
the On_StartupComplete event handler provided by the IDTExtensibility2
interface.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
news:A3C74B85-AC55-4596-8ACD-0AC5DEAF4278[ at ]microsoft.com...
[Quoted Text]
> Hi Ken,
>
> This is a COM AddIn. I create it with VB6.I have a deafult template of
> outlook project on it and then I use the dll to install it on users
> machines.
> I check everything that come if it's "IPM.Note"
> FormDescription.MessageClass. If it is the code is process.
>
> Is there anything else to check in addition to check the logic again ?
>
> Thanks
> David

Re: New mail event doesn't work all time
DavidE 2/18/2007 1:37:05 PM
Hi Ken,
Sorry for my late reply,I wasn't here.

I'll try to work with those events.

Thanks,

David


"Ken Slovak - [MVP - Outlook]" wrote:

[Quoted Text]
> If this is a COM addin why are you using the Application_Startup()
> procedure? In many or most cases it will fire before your addin is started
> by Outlook. You would want to use either the On_Connection event handler or
> the On_StartupComplete event handler provided by the IDTExtensibility2
> interface.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "DavidE" <DavidE[ at ]discussions.microsoft.com> wrote in message
> news:A3C74B85-AC55-4596-8ACD-0AC5DEAF4278[ at ]microsoft.com...
> > Hi Ken,
> >
> > This is a COM AddIn. I create it with VB6.I have a deafult template of
> > outlook project on it and then I use the dll to install it on users
> > machines.
> > I check everything that come if it's "IPM.Note"
> > FormDescription.MessageClass. If it is the code is process.
> >
> > Is there anything else to check in addition to check the logic again ?
> >
> > Thanks
> > David
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net