jonlake
asked on
Count items in MS Outlook Outbox
Hi, I am trying to use VBA from within MS Access to count the number of items sitting in a users MS Outlook outbox. The challenge is that the user default folder name is going to be different from user to user. So, what I need is for the VBA to find the default folder name and the pass it into the code. Here is what I have (currently counting sent items), which works when specifying the name:
Dim objOutlook As Object, objnSpace As Object, objFolder As MAPIFolder
Dim EmailCount As Integer
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objnSpace = objOutlook.GetNamespace("M API")
On Error Resume Next
Set objFolder = objnSpace.Folders("Google Apps - bob.smith@emailbox.com").F olders("Se nt Items")
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
EmailCount = objFolder.Items.Count
MsgBox "Number of emails in the folder: " & EmailCount, , "email count"
Dim objOutlook As Object, objnSpace As Object, objFolder As MAPIFolder
Dim EmailCount As Integer
Set objOutlook = CreateObject("Outlook.Appl
Set objnSpace = objOutlook.GetNamespace("M
On Error Resume Next
Set objFolder = objnSpace.Folders("Google Apps - bob.smith@emailbox.com").F
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
EmailCount = objFolder.Items.Count
MsgBox "Number of emails in the folder: " & EmailCount, , "email count"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER