Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / General MS Outlook Questions / March 2008

Tip: Looking for answers? Try searching our database.

Referencing a particular email box via VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GLT - 29 Feb 2008 01:55 GMT
Hi,

I am trying to import messages from a shared email box (not my own).

Currently I have the shared email box open up when outlook starts.

This code is what I execute to import messages:

' Set up Outlook objects.
  Dim ol As New Outlook.Application
  Dim olns As Outlook.Namespace
  Dim c As Outlook.MailItem
  Dim objItems As Outlook.Items
  Dim objFolder As Outlook.MAPIFolder

 FolderName = "ResultsFolder"
  Set olns = ol.GetNamespace("MAPI")
  Set objFolder = olns.GetDefaultFolder(olFolderInbox).Folders(FolderName)
  Set objItems = objFolder.Items

I would like anyone of my team members to be able to execute this code and
the messages are imported from the shared email box.

How do I reference a particular email box (email box name: SharedTeam) in
the code above?

Cheers,
GLT.
Ken Slovak - [MVP - Outlook] - 29 Feb 2008 14:06 GMT
Look at the Object Browser Help on the NameSpace.GetSharedDefaultFolder()
method.

Signature

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

> Hi,
>
[quoted text clipped - 24 lines]
> Cheers,
> GLT.
GLT - 06 Mar 2008 06:43 GMT
Hi Ken,

Thanks for your reply,

I tried using this and unfortuanetly I cannot get this working.

I still need to get my team members to add this email box to their profiles
in order for it to work.

Is there a way that people can execute VBA code without having to add the
users email box to their profiles (ie via the control panel).

Can you point me to any particaulr examples of this?

Cheers,
GLT

> Look at the Object Browser Help on the NameSpace.GetSharedDefaultFolder()
> method.
[quoted text clipped - 27 lines]
> > Cheers,
> > GLT.
Ken Slovak - [MVP - Outlook] - 06 Mar 2008 14:35 GMT
It should be pretty simple. If the shared mailbox name is "SharedTeam" then
something like this should work:

 Dim oRecip As Outlook.Recipient
 Dim oFolder As Outlook.MAPIFolder
 Dim oNS As Outlook.NameSpace
 Dim oSubFolder As Outlook.MAPIFolder

 Set oNS = Application.GetNamespace("MAPI")
 Set oRecip = oNS.CreateRecipient("SharedTeam")
 oRecip.Resolve
 If oRecip.Resolved Then
     Set oFolder = oNS.GetSharedDefaultFolder(oRecip, olFolderInbox)
     Set oSubFolder = oFolder.Folders("Foobar Contacts")

     If Not (oSubFolder Is Nothing) Then
       MsgBox "Item 1 = " & oSubFolder.Items.Item(1).Subject
     Else
       MsgBox "Could not get folder"
     End If
 End If

Signature

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

> Hi Ken,
>
[quoted text clipped - 13 lines]
> Cheers,
> GLT
GLT - 11 Mar 2008 10:57 GMT
Hi Ken,

Thanks for your help - works perfectly.

Cheers,
GLT

> It should be pretty simple. If the shared mailbox name is "SharedTeam" then
> something like this should work:
[quoted text clipped - 35 lines]
> > Cheers,
> > GLT
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.