![]() |
Type Mismatch when iterating through eMail-folder MailItems in Outlook 2003
Hi all,
In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes |
Type Mismatch when iterating through eMail-folder MailItems in Outlook 2003
So, let's play detective. If the code works on some mail items but not
others I'd doubt it's a problem that can be solved by repair/reinstall/whatever, see if there are differences that you can find with the items where the macro works and where it doesn't. The other thing to check is why you're getting an error of MAPI_E_NOT_FOUND for those items. Google on that error code and see if any of the reasons that you're getting MAPI_E_NOT_FOUND apply to you. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm wrote in message ps.com... Hi all, In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes |
Type Mismatch when iterating through eMail-folder MailItems in Outlook 2003
On 4 Okt., 16:50, "Ken Slovak - [MVP - Outlook]"
wrote: So, let's play detective. If the code works on some mail items but not others I'd doubt it's a problem that can be solved by repair/reinstall/whatever, see if there are differences that you can find with the items where the macro works and where it doesn't. The other thing to check is why you're getting an error of MAPI_E_NOT_FOUND for those items. Google on that error code and see if any of the reasons that you're getting MAPI_E_NOT_FOUND apply to you. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm wrote in message ps.com... Hi all, In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes Thanks for your reply. Since some MailItems work on one machine but not one the other, I guess it could be an installation or configuration issue - not necessarily with Office itself, but perhaps with any other software? I'll try installing SP3 or using an older or newer Outlook version (2002 or 2007), maybe it works then. I didn't find anything on the web concerning my issue and the MAPI_E_NOT_FOUND error that would bring any hints. The messages that don't work show no difference to me from the ones that work - I can use/modify them directly in Outlook with no problems. Only in VBA they seem to differ. Strange behaviour. Thanks in advance. Regards, Hannes |
Type Mismatch when iterating through eMail-folder MailItems in Outlook 2003
If you have a MAPI viewer such as OutlookSpy (www.dimastr.com) it often
shows differences in properties that you don't see in the user interface. I'd also suspect permissions issues possibly if the code works with the same items on one setup and not the other. See that the permissions are for the users represented by those Outlook logons. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm wrote in message oups.com... snip Thanks for your reply. Since some MailItems work on one machine but not one the other, I guess it could be an installation or configuration issue - not necessarily with Office itself, but perhaps with any other software? I'll try installing SP3 or using an older or newer Outlook version (2002 or 2007), maybe it works then. I didn't find anything on the web concerning my issue and the MAPI_E_NOT_FOUND error that would bring any hints. The messages that don't work show no difference to me from the ones that work - I can use/modify them directly in Outlook with no problems. Only in VBA they seem to differ. Strange behaviour. Thanks in advance. Regards, Hannes |
All times are GMT +1. The time now is 03:36 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com