A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to identify a mail item from a public folder in MS Outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 10th 09, 04:46 AM posted to microsoft.public.outlook.program_vba
DPM
external usenet poster
 
Posts: 21
Default How to identify a mail item from a public folder in MS Outlook

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  
Old November 10th 09, 07:02 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How to identify a mail item from a public folder in MS Outlook



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  
Old November 10th 09, 12:56 PM posted to microsoft.public.outlook.program_vba
DPM
external usenet poster
 
Posts: 21
Default How to identify a mail item from a public folder in MS Outlook

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  
Old November 10th 09, 01:46 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default How to identify a mail item from a public folder in MS Outlook

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  
Old November 10th 09, 08:54 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How to identify a mail item from a public folder in MS Outlook



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  
Old November 10th 09, 09:46 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default How to identify a mail item from a public folder in MS Outlook

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 03:37 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-2025 Outlook Banter.
The comments are property of their posters.