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.


0
DPM
11/10/2009 4:46:53 AM
outlook.program_vba 490 articles. 0 followers. Follow

5 Replies
838 Views

Similar Articles

[PageSpeed] 22


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.
0
Michael
11/10/2009 7:02:47 AM
Thanks Michael,
Also found that the Class property returns 43 for a MailItem


"Michael Bauer [MVP - Outlook]" <mb@mvps.org> wrote in message 
news: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. 


0
DPM
11/10/2009 12:56:20 PM
To add to what Michael wrote, use a custom function for this. i.e.

Function IsMailItem(Itm As Object) As Boolean
  IsMailItem =3D (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=A0am, "DPM" <a...@bb.cc> wrote:
> Thanks Michael,
> Also found that the Class property returns 43 for a MailItem
>
> "Michael Bauer [MVP - Outlook]" <m...@mvps.org> wrote in messagenews:h56y=
tjpn3c14.6qdv44grfkcn$.dlg@40tude.net...
>
>
>
>
>
> > Instead of checking the folder's DefaultItemType property, you can chec=
k
> > 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
>
> > =A0: Outlook Categories? Category Manager Is Your Tool
> > =A0: VBOffice Reporter for Data Analysis & Reporting
> > =A0: <http://www.vboffice.net/product.html?pub=3D6&lang=3Den>
>
> > 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 =3D CREATEOBJECT("OutLook.Application")
> >> loNameSpace =3D loOutlookSession.GetNameSpace("MAPI")
> >> loMailFolder =3D loNameSpace.PickFolder()
> >> IF loMailFolder.DefaultItemType =3D 0
> >> =A0 =A0 ** 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 -

0
JP
11/10/2009 1:46:54 PM

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" <a...@bb.cc> wrote:
>> Thanks Michael,
>> Also found that the Class property returns 43 for a MailItem
>>
>> "Michael Bauer [MVP - Outlook]" <m...@mvps.org> 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 -
0
Michael
11/10/2009 8:54:43 PM
It's encapsulation, Michael. Besides, it's not going to change the
number of iterations.

--JP


On Nov 10, 3:54=A0pm, "Michael Bauer [MVP - Outlook]" <m...@mvps.org>
wrote:
> What an overhead.
>
> --
> Best regards
> Michael Bauer - MVP Outlook
>
> =A0 : Outlook Categories? Category Manager Is Your Tool
> =A0 : VBOffice Reporter for Data Analysis & Reporting
> =A0 : <http://www.vboffice.net/product.html?pub=3D6&lang=3Den>
>
> 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
> > =A0 IsMailItem =3D (Typeof Itm is Outlook.MailItem)
> > End Function
>
> > Then call the function in your loop:
>
> > Dim obj as Object
> > For Each obj in Items
> > =A0 If IsMailItem(obj) Then ...
>
> > Next obj
>
> > --JP
>
0
JP
11/10/2009 9:46:15 PM
Reply:

Similar Artilces:

Problems with Public Folders replication
Hi guys, Some problems here. We have decided to install Exchange server 2003 SP1 on a new hardware with W2k3 SP1 on a new DC (yes, I know it is a bad practice, but...) instead of old Exchange server 2003 SP1 on an old DC on an old hardware. New one (additional) DC was brought live (with some minor problems, DNS, time, as always) without FSMO delegation (for now). Replication of users' accounts was smooth. Logs clear. After Exchange 2003 SP1 installation (with some DNS manipulations) also all was Ok. Dcdiag Ok. In ESM all Exchange servers are visible (old and new). So I have started ...

Want to add new folder to all existing mailboxes
Hello, I'm trying to find a way to add a "junk mail" folder to every mailbox in my site without having to log into each one manually. any ideas thank e "Eric" <ehansen@aruplab.nospam.com> wrote: >Hello, I'm trying to find a way to add a "junk mail" folder to every mailbox in my site without having to log into each one manually. any ideas? >thanks >e Well, if you've got an anti virus or anti spam product that's Exchange integrated then the package will generate them automatically. If you haven't, then deply Outlook 2003. If y...

Take a look at security pack for MS Windows
--yibeujjlfx Content-Type: multipart/related; boundary="vyjaaasi"; type="multipart/alternative" --vyjaaasi Content-Type: multipart/alternative; boundary="mxqquhmmrnwjoq" --mxqquhmmrnwjoq Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS Consumer this is the latest version of security update, the "September 2003, Cumulative Patch" update which resolves all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to protect your...

Can I send a recurring e-mail automatically each week
I want to send a e-mail with the same verbiage to the same person once a week and make it a recurrence with no end date. Can I set this up once in Outlook so it is scheduled automatically? -- Microsoft Office 2003 Version Students and Teachers Edition Windows Vista Home Premium Thank-you Happy new Year!! Carl R ...

Transferring over outlook data to new XP machine
How do I transfer over my old emails, address book to my new XP machine? I have looked over the internet and found nothing the tells me EXACTLY how to do this, any help would be greatly appreciated. senior_tech@yahoo.com If your using MS Outlook copy your .PST file across and import it into the new install. >If your using MS Outlook copy your .PST file across and import it into the new install. No, don't import it. Simply use "File">"Open" -- Brian Tillman Smiths Aerospace 3290 Patterson Ave. SE, MS 1B3 Grand Rapids, MI 49512-1991 Brian.Tillman is the nam...

Outlook 2003 and "Check Names"
Hi, We are testing Outlook 2003 at our office now and there is one very frustrating "feature" that is bugging all of us. When we create a new e-mail message and type in the first name of a person from the global address book and hit ctrl- k to check the name...we get a response that Outlook doesn't recognize the name and there are "no suggestions". The only way Check Name will successfully resolve the name is if we type it last name first (ie, Gates, Bill). This was not the case in Office XP or Outlook 2000. You could search by first name (or partial first name)...

Crash on 'Send"
My wife's Intel Celeron running ME started having this problem sporadically - now constantly. Outlook 2000 receives OK - everything seems fine until you hit the 'Send' button then Outlook crashes giving an error message that says 'Outlook has caused an error in <unknown> and has to shut down. If the problem persists you may have to restart your computer.' Re-starting however has no effect. I have re-installed Office. Used 'Detect & Repair' under the 'Help' tab, and installed all patches/updates from the Office site. But this error continues, now...

Outlook 2003 keeps crashing #2
I get this message when I look in System information. Outlook keeps crashing quite often. I cannot for example delete two messages without outlook crashing. My colleagues do not have this problem. We are using the Microsoft mail exhange server. Faulting application outlook.exe, version 11.0.5510.0, stamp 3f1380f0, faulting module mso.dll, version 11.0.5606.0, stamp 3f334cce, debug? 0, fault address 0x003b6e16. Does anyone has a solution?=20 Best regards/ Bj=F6rn 1) I would definitely apply Service Pack 2for Office 2003 + applicable critical security updates. 2) Have you tried starting O...

Password Issue with MS Money 2003
Hello, I am not familiar with newsgroups but I hope it is a forum to seek assistance. I am unable to reach MS support via email from my home computer on this issue. My Money 2003 requires a net passport password to open my account in Money that I have successfully accessed for approximately 12 months. It does not recognize my password now. I have attempted several times with my existing password, changed my net passport password, even uninstalled and re- installed MS Money 2003 to gain access to my account. Nothing has worked. Each time it states I have failed to enter the corr...

Outlook needs Outlook Express to work
I've installed my Outlook 2002 on my new Vista PC (I had Xp before). Now when I start Outlook it says "requires Outlook Express 4.01 or greater". I've been looking for Outlook Express to download and install but no joy. No CD came with my new Vista PC. Any ideas, short of buying a more modern Outlook? Vista doesn't actually support Outlook 2002 or older. Outlook Express is part of Internet Explorer but with the advent of Vista, it was switched to Windows Mail. There is no more Outlook Express. You could attempt however to create a profile using workgroup or c...

"The connection to the Exchange server is unavailable. Outlook must be online or connected to complete this action"
I have setup a number of user accounts and the relative mailboxes without any problem. However, since this afternoon, if I try and connect to a newly mailbox through the email accounts wizard I get the following error message: "The connection to the Exchange server is unavailable. Outlook must be online or connected to complete this action". This also occurs when I go to File>Open>Other User's Folder... and I try and lookup an existing account/mailbox that I know I have permission to. I know Outlook is connected to the Exchange server (I can ping, send and receive emails) ...

MS Money 95 data files
I hope that some one can answer this for me. I have used MS Money 95 for years, and it works just fine for me on Windows XP, however, I now have to reformat my hard drive, and have discovered that I can nolonger find my original install disk. Will the latest versions of Money still read the MS Money 95 data files. All that I have ever used the program for is to track my investments, and am unlikely to do any different in the future. Thanks Stan B In microsoft.public.money, Stan Banner wrote: >I hope that some one can answer this for me. >I have used MS Money 95 for years, and...

Recieve Mail Before Sending
How do I set up Outlook 2003 to recieve mail before sending Set your send/receive group settings to receive and not send. Or are you talking about setting authentication? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer: Keith <anonymous@discussions.microsoft.com> asked: | How do I set up Outlook 2003 to recieve mail before sending ...

sharing of folders
I tried configuring my folder to share it with the others but unfortunately as i tour around the outlook i could find the permissions tab when i right click the properties of a certain folder. What should I do with this problem? Is there other way in order I could share my folder? Pls. help Thanks and regards You'll have to tell us more about your Outlook version and mail environment. In the meantime, you might want to take a look at http://www.slipstick.com/outlook/share.htm -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Po...

[Exchange 2003] Mail enabled public folder and sender address
I have a Windows 2003 domain with a native mode Exchange 2003 organization; there are some mail enabled public folders. When a user replies to a message in a public folder, the outgoing mail's sender address is the user's one; I want it to be the public folder's one, or at least I'd like the "reply-to" address to be set to the public folder's. How can I accomplish this? Thanks Massimo You would need to grant the user permissions to be able to Send As the public folder. By default, when you reply to a message that is in a PF, the PF is not composing the ...

cant start outlook pst file to large
Hi I hope somebody may be able to help im new to outlook and now I cant start outlook message says cannot open your default email folders pst file its too large as I cannot open outlook I cannot delete old folders See if this helps: http://support.microsoft.com/kb/296088 -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide to Microsoft Outlook 2007: http://tinyurl.com/ol4law-amazon "Ray" <Ray@discussions.microsoft.com> wrote in message news:B3B824DC-3C9B-4B1B-8EF3-61...

Change File Locations to Private Drive (not Folder)
Hi, I know that I can use "File Locations" in "Options" so that whenever I use the "Open..." command in Word, it will open to a specific folder. I'm wondering if there is a way that this can be applied not to a folder but to a specific drive on a network. Our company has a main public drive and has also assigned each of the Staff their own private drive. Is there a way to access the "main page" (for lack of a better term) of my private drive each time I use "Open..." in Word? Right now it goes to "My Computer" or ...

How to get rid of personal folders view in nagivation pane with MA
Hi, trying to help a friend who migrated to hosted mail with MAPI. She is running Oultlook 2003 with latest updates. In the navigation there are personal folders and MAPI folders. The personal folders always show at top and expanded, with the MAPI folders below and not expanded. She only wants to see the MAPI folders expanded in the navigation view. I tried deleting the personal folders and it would not let me and it will not let you deliver to MAPI, which I understand why. Does anyone know how to make this happen? Thanks. Is this a hosted Exchange account? You can change the...

Outlook 2003
Hello, we have one client pc with Outlook 2003 where the following problem occurs: if a mail is replied from a user created sub folder of the inbox, the reply will not appear in sent mails, but will end up in the same sub folder, sender and recipient appear as identical. The mail goes out properly though, it's just that Outlook sets internally sender = recipient and bounces the reply back to the subfolder in which the original mail is stored. This happens on a Win 2000 machine with SP4 and all updates, the other clients use Outlook 2000 or XP and there is no such problem. There are no ru...

"MS Money 2000" mit kostenlosem HBCI-Modul (HBCIFM99) kompatibel?
Hallo, Gruppe, wollte mal fragen, ob das o. g. HBCI-Modul auch mit "MS Money 2000" (also - wenn ich das richtig verstanden habe - mit der letzten deutschen Version von "MS Money" 1999/2000 aus �sterreich/der Schweiz) kompatibel ist. Vielen Dank schon im voraus f�r Eure Hilfe. Gru� Struppi Roughly translated: ------------------------- Hello, Group, I wanted to ask whether the o. g. HBCI module also with "MS Money 2000" (also - if I understood correctly that - with the last German version of "MS Money" 1999/2000 from Austria/Switzerland) is compatib...

Outlook "Ruler" won't go away
I don't know how I turned this on so I don't know how to turn it off. It splits my emails so that I can only type so far over before it kicks me back to the left margin and makes me start a new line. Can anyone help me? ...

Reminders in Outlook
Since upgrading to Great Plains 9.0, several users are not getting their appointment reminders in Outlook 2003. They all show up at once after rebooting computer. Outlook settings are set appropriately. Any ideas? -- Steve ...

how do i add "Software Digrams" Folder in my Visio 2003
how do i add software diags folder in visio 2003 version. Like if i go to File->New it shows folders like brainstorming, project schedule, block diagrams but in my case its missing the Software Diags folder which contains activity diags, web mock ups, use case diags etc. please let me know how to get that template. thanks. Ankur What edition of Visio are you using? Check by going to the About Microsoft Office Visio dialog from the Help menu. "Ankur" <Ankur@discussions.microsoft.com> wrote in message news:F0D10BF0-A059-4A9C-B615-B99F3916F4E5@microsoft.com... > how...

Mail lMerge
Sorry folks. I asked a question and went to the hospital for a while and the question expired. I have an address list in excel 2007 and am using word 2007. In my address list I have a code column which should allow the selection of addresses to put on labels. I used to have a query section what allows for that but I cannot find query any more. can anyone help me? charles Questions here never expire, though it may become difficult to find the answer. The previous post received one reply, from Doug Robbins, as follows: See the article "Mailmerge Labels with Word ...

How To Copy MS Word mailing labels into Excel
I have a word doc that I want to put into Excel. I want to add some more fields to the names and addresses. Is this simple or do I have to learn how to program? Michael Rodriguez City of Grand Prairie Michael, have you tried to copy and paste the data into excel? -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Michael Rodriguez" <mrodrigu@gptx.org> wrote in messa...