![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi,
I have developed an application which read mails from a user selected folder of MS Outlook. Following is a code sample. loOutlookSession = CREATEOBJECT("OutLook.Application") loNameSpace = loOutlookSession.GetNameSpace("MAPI") loMailFolder = loNameSpace.PickFolder() IF loMailFolder.DefaultItemType = 0 ** This is a folder with mail items ENDIF This works fine as long as a mail folder is selected but if the user selects a public folder it does not imports its mails as the public folder's DefaultItemType property returns 6. I noticed that these public folders could have items other than mails, such as tasks, contacts, ect.. Therefore even if public folders are allowed to import mails from it, it fails when there are non mail items in the public folder. To avoid this could someone please advice how to identify a mail item from the rest of the non mail items in the public folder. |
#2
|
|||
|
|||
![]() Instead of checking the folder's DefaultItemType property, you can check each item's object type. For instance: Dim obj as Object For Each obj in Items If Typeof obj is Outlook.MailItem Then ... Next -- Best regards Michael Bauer - MVP Outlook : Outlook Categories? Category Manager Is Your Tool : VBOffice Reporter for Data Analysis & Reporting : http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 10:16:53 +0530 schrieb DPM: Hi, I have developed an application which read mails from a user selected folder of MS Outlook. Following is a code sample. loOutlookSession = CREATEOBJECT("OutLook.Application") loNameSpace = loOutlookSession.GetNameSpace("MAPI") loMailFolder = loNameSpace.PickFolder() IF loMailFolder.DefaultItemType = 0 ** This is a folder with mail items ENDIF This works fine as long as a mail folder is selected but if the user selects a public folder it does not imports its mails as the public folder's DefaultItemType property returns 6. I noticed that these public folders could have items other than mails, such as tasks, contacts, ect.. Therefore even if public folders are allowed to import mails from it, it fails when there are non mail items in the public folder. To avoid this could someone please advice how to identify a mail item from the rest of the non mail items in the public folder. |
#3
|
|||
|
|||
![]()
Thanks Michael,
Also found that the Class property returns 43 for a MailItem "Michael Bauer [MVP - Outlook]" wrote in message ... Instead of checking the folder's DefaultItemType property, you can check each item's object type. For instance: Dim obj as Object For Each obj in Items If Typeof obj is Outlook.MailItem Then ... Next -- Best regards Michael Bauer - MVP Outlook : Outlook Categories? Category Manager Is Your Tool : VBOffice Reporter for Data Analysis & Reporting : http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 10:16:53 +0530 schrieb DPM: Hi, I have developed an application which read mails from a user selected folder of MS Outlook. Following is a code sample. loOutlookSession = CREATEOBJECT("OutLook.Application") loNameSpace = loOutlookSession.GetNameSpace("MAPI") loMailFolder = loNameSpace.PickFolder() IF loMailFolder.DefaultItemType = 0 ** This is a folder with mail items ENDIF This works fine as long as a mail folder is selected but if the user selects a public folder it does not imports its mails as the public folder's DefaultItemType property returns 6. I noticed that these public folders could have items other than mails, such as tasks, contacts, ect.. Therefore even if public folders are allowed to import mails from it, it fails when there are non mail items in the public folder. To avoid this could someone please advice how to identify a mail item from the rest of the non mail items in the public folder. |
#4
|
|||
|
|||
![]()
To add to what Michael wrote, use a custom function for this. i.e.
Function IsMailItem(Itm As Object) As Boolean IsMailItem = (Typeof Itm is Outlook.MailItem) End Function Then call the function in your loop: Dim obj as Object For Each obj in Items If IsMailItem(obj) Then ... Next obj --JP On Nov 10, 7:56*am, "DPM" wrote: Thanks Michael, Also found that the Class property returns 43 for a MailItem "Michael Bauer [MVP - Outlook]" wrote in messagenews:h56ytjpn3c14.6qdv44grfkcn$.dlg@40tude. net... Instead of checking the folder's DefaultItemType property, you can check each item's object type. For instance: Dim obj as Object For Each obj in Items If Typeof obj is Outlook.MailItem Then ... Next -- Best regards Michael Bauer - MVP Outlook *: Outlook Categories? Category Manager Is Your Tool *: VBOffice Reporter for Data Analysis & Reporting *: http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 10:16:53 +0530 schrieb DPM: Hi, I have developed an application which read mails from a user selected folder of MS Outlook. Following is a code sample. loOutlookSession = CREATEOBJECT("OutLook.Application") loNameSpace = loOutlookSession.GetNameSpace("MAPI") loMailFolder = loNameSpace.PickFolder() IF loMailFolder.DefaultItemType = 0 * * ** This is a folder with mail items ENDIF This works fine as long as a mail folder is selected but if the user selects a public folder it does not imports its mails as the public folder's DefaultItemType property returns 6. I noticed that these public folders could have items other than mails, such as tasks, contacts, ect.. Therefore even if public folders are allowed to import mails from it, it fails when there are non mail items in the public folder. To avoid this could someone please advice how to identify a mail item from the rest of the non mail items in the public folder.- Hide quoted text - - Show quoted text - |
#5
|
|||
|
|||
![]() What an overhead. -- Best regards Michael Bauer - MVP Outlook : Outlook Categories? Category Manager Is Your Tool : VBOffice Reporter for Data Analysis & Reporting : http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 05:46:54 -0800 (PST) schrieb JP: To add to what Michael wrote, use a custom function for this. i.e. Function IsMailItem(Itm As Object) As Boolean IsMailItem = (Typeof Itm is Outlook.MailItem) End Function Then call the function in your loop: Dim obj as Object For Each obj in Items If IsMailItem(obj) Then ... Next obj --JP On Nov 10, 7:56*am, "DPM" wrote: Thanks Michael, Also found that the Class property returns 43 for a MailItem "Michael Bauer [MVP - Outlook]" wrote in messagenews:h56ytjpn3c14.6qdv44grfkcn$.dlg@40tude. net... Instead of checking the folder's DefaultItemType property, you can check each item's object type. For instance: Dim obj as Object For Each obj in Items If Typeof obj is Outlook.MailItem Then ... Next -- Best regards Michael Bauer - MVP Outlook *: Outlook Categories? Category Manager Is Your Tool *: VBOffice Reporter for Data Analysis & Reporting *: http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 10:16:53 +0530 schrieb DPM: Hi, I have developed an application which read mails from a user selected folder of MS Outlook. Following is a code sample. loOutlookSession = CREATEOBJECT("OutLook.Application") loNameSpace = loOutlookSession.GetNameSpace("MAPI") loMailFolder = loNameSpace.PickFolder() IF loMailFolder.DefaultItemType = 0 * * ** This is a folder with mail items ENDIF This works fine as long as a mail folder is selected but if the user selects a public folder it does not imports its mails as the public folder's DefaultItemType property returns 6. I noticed that these public folders could have items other than mails, such as tasks, contacts, ect.. Therefore even if public folders are allowed to import mails from it, it fails when there are non mail items in the public folder. To avoid this could someone please advice how to identify a mail item from the rest of the non mail items in the public folder.- Hide quoted text - - Show quoted text - |
#6
|
|||
|
|||
![]()
It's encapsulation, Michael. Besides, it's not going to change the
number of iterations. --JP On Nov 10, 3:54*pm, "Michael Bauer [MVP - Outlook]" wrote: What an overhead. -- Best regards Michael Bauer - MVP Outlook * : Outlook Categories? Category Manager Is Your Tool * : VBOffice Reporter for Data Analysis & Reporting * : http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 10 Nov 2009 05:46:54 -0800 (PST) schrieb JP: To add to what Michael wrote, use a custom function for this. i.e. Function IsMailItem(Itm As Object) As Boolean * IsMailItem = (Typeof Itm is Outlook.MailItem) End Function Then call the function in your loop: Dim obj as Object For Each obj in Items * If IsMailItem(obj) Then ... Next obj --JP |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Failing to Move Item from Public Folder to Local Folder | Clifford | Outlook and VBA | 1 | November 9th 07 04:39 PM |
identify reply programmatically for mail item | BiangL | Outlook and VBA | 4 | October 28th 07 01:34 AM |
Public folder Item and Default Contacts | David Parkes | Outlook - General Queries | 1 | December 23rd 06 03:32 PM |
How to identify item in DistList that's also in Contacts? | gxdata | Outlook and VBA | 3 | August 8th 06 06:09 PM |
How to read Item from Public Folder and process it DIRECTLY. | gata | Outlook - General Queries | 4 | July 7th 06 06:15 AM |