How to calculate the email statistics of 'on behalf of' (outbound) in amailbox using vba script?

C

Chew Ling

Hello, I'm having a problem here. Currently I need to calculate number of emails based on 'on behalf of'. There's multiple mailbox and the user have to choose which mailbox he/she wants to calculate. I do not know how to identify or recognized which mailbox did the user select. Is there anyway that I can know which mailbox does the user select? Please help or reply ASAP as I need it urgently!

The codings that I've tried:

Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim sender As Outlook.AddressEntries
Dim olParentFolder, olFolderA As Outlook.MAPIFolder
Dim olMAPI As Object
Dim mymailbox As Object
Set olApp = CreateObject ("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
set olMAPI = GetObject("", "Outlook.Application").GetNamespace("MAPI")
Set olParentFolder = olNs.PickFolder
mymailbox = Application.GetNamespace("MAPI").GetDefaultFolder().Parent.Name
outbound_counter = 0
sender_name1 = sender_name.Value
For Each olFolderA In olParentFolder.Folders
Set email_Item = olFolderA.Items
For Each email_Item In olFolderA.Items
If email_Item.Class = olMail Then
sender_name2 = email_Item.SenderName
mymailbox = Application.GetNamespace("MAPI").GetDefaultFolder(olParentFolder).Parent.Name
If mymailbox = sender_name2 Then
outbound_counter = outbound_counter + 1
End If
End If
I tried the olParentFolder for the GetDefaultFolder but it says type mismatch. :((
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top