• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to check each draft item from all the shared inbox

ThrottleWorks

Excel Ninja
Hi,

Brief about macro. This macro needs to check each draft e-mail from Outlook for certain rules. The code I have written works well for conditions set.

However my problem is, the user has multiple inbox in his outlook. One is his personal inbox, others are shared inbox. Numbers of shared inbox for a user can vary. It can be 3,4,5 or 7. This number is not fixed.

How do I check draft item from each Inbox. The code I have written works only for personal Inbox. Given below.

Can anyone please help me in this.
Have a nice weekend. :)

Code:
Public Sub Chandoo()
    Dim strT As String
    Dim strC As String
    Dim strBC As String
    Dim strSubjec As String
    Dim strBOD As String
  
    Set MacroBook = ThisWorkbook
  
    universalFunction = False
  
    Call StartMacro
  
    AttachmentFlag = False
  
    Call setOutlookObjects

    Call onScreen
End Sub
Public Sub StartMacro()
    Application.EnableCancelKey = False
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
End Sub
Function setOutlookObjects() 'Required
    Set myOutlook = Outlook.Application
    Set myNamespace = myOutlook.GetNamespace("MAPI")
    Set myFolders = myNamespace.Folders
    Set myDraftsFolder = myNamespace.GetDefaultFolder(olFolderDrafts)
    Set myItems = myDraftsFolder.Items
    Set myItem = myItems.Find("[Categories] = ''")
  
    validationStatus = vbNullString
    validationStatus = "Chandoo"
End Function
Function onScreen()
  
    Dim osCounter As Integer
    Dim oApp As New Outlook.Application
    Dim oins As Outlook.Inspector
    Dim osStatussheetOBJ As Object
  
    Call sheetAdd
  
    Set osStatussheetOB = Nothing
    Set osStatussheetOB = ThisWorkbook.Worksheets("MySheet")
  
    osStatussheetOB.UsedRange.Offset(1, 0).ClearContents
    oncounter = 0
    universalInc = 0
  
    For Each oins In oApp.Inspectors
        UniversalStringStatus = vbNullString
        universalInc = universalInc + 1
      
        '----------------------------------------
        Dim outlookApp
        Dim olNs As Outlook.Namespace
        Dim Fldr As Outlook.MAPIFolder
        Dim olMail As Variant
        Dim myTasks
        Dim sir() As String
      
        Set outlookApp = CreateObject("Outlook.Application")
        Set olNs = outlookApp.GetNamespace("MAPI")
        Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
        Set myTasks = Fldr.Items
      
        'my code, not given here
    Next
End Function
Function sheetAdd() 'Required
    ThisWorkbook.Activate
    Worksheets("MySheet").Select
    ActiveSheet.Unprotect Password:="Chandoo"
    ActiveSheet.Cells.Clear
  
    Set Status_Sht = ActiveSheet
End Function
 
Hi sir,

I guess, the code at Stackoverflow will work if we know name of another 'Inbox'.
In my case, I will be to able know name of another 'Inbox'.

There may be n number of Inbox. Also, macro will be used by different users.
And each user can have different number and names and inbox.

How do I get name of each inbox from the outlook and pass it in the code.
Something like loop.

Could you please help if you get time.
 
Back
Top