Consulting

Results 1 to 2 of 2

Thread: Incoming email to non default mailbox

  1. #1
    VBAX Newbie
    Joined
    Nov 2013
    Posts
    1
    Location

    Angry Incoming email to non default mailbox

    I am trying to figure out how to catch an incoming email to a non default mailbox. So I have two mailboxes. My work email mailbox (I am on exchange server) and a shared mailbox. I need to test incoming mail items into the shared mailbox (which i added through advanced settings in my default advanced options). I try application.newmail, but it isnt catching items into the shared mailbox, just the default on. How do I do this? I have been search all over the place.

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    The basic idea is here http://www.outlookcode.com/article.aspx?id=62

    Option Explicit
     
    Private WithEvents olInboxItems As Items
     
    Private Sub Application_Startup()
      Dim objNS As NameSpace
      Set objNS = Application.Session
      ' instantiate objects declared WithEvents
      Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
      Set objNS = Nothing
    End Sub
     
    Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
       ' do something
    End Sub
    Instead of
    Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items

    try this more general format
    Set olInboxItems = objNS.Folders("name of shared mailbox”).Folders("Inbox").Items
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •