A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

get outlook mailbox size from vba



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 11th 07, 01:44 PM posted to microsoft.public.outlook.program_vba
BobM
external usenet poster
 
Posts: 7
Default get outlook mailbox size from vba

Hello,

I am looking for some VBA code to get the Outlook Mailbox size on the
exchange server from Access.

I found this url http://support.microsoft.com/kb/320071 but not support by
VBA.

I am sending email from Access using the Outlook SendObject and before
sending I want to check the Mailbox size to ensure the Mailbox size is under
the size quota.

Appreciate any help.

bobm
  #2  
Old August 11th 07, 02:08 PM posted to microsoft.public.outlook.program_vba
BobM
external usenet poster
 
Posts: 7
Default get outlook mailbox size from vba

Sub GetFolderSize()
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objOutlookToday = objInbox.Parent

For Each objSubFolder In objOutlookToday.Folders
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next
MsgBox "Total Size = " & lFolderSize
End Sub

Function GetSubFolderSize(objFolder As MAPIFolder) As Long
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

For Each objItem In objFolder.Items
lFolderSize = lFolderSize + objItem.Size
Next

' process all the subfolders of this folder
For Each objSubFolder In objFolder.Folders
'Do something with objFolder
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next

GetSubFolderSize = lFolderSize
Set objFolder = Nothing
Set objItem = Nothing
End Function
  #3  
Old August 11th 07, 02:08 PM posted to microsoft.public.outlook.program_vba
BobM
external usenet poster
 
Posts: 7
Default get outlook mailbox size from vba

Sub GetFolderSize()
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objOutlookToday = objInbox.Parent

For Each objSubFolder In objOutlookToday.Folders
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next
MsgBox "Total Size = " & lFolderSize
End Sub

Function GetSubFolderSize(objFolder As MAPIFolder) As Long
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

For Each objItem In objFolder.Items
lFolderSize = lFolderSize + objItem.Size
Next

' process all the subfolders of this folder
For Each objSubFolder In objFolder.Folders
'Do something with objFolder
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next

GetSubFolderSize = lFolderSize
Set objFolder = Nothing
Set objItem = Nothing
End Function
  #4  
Old October 10th 07, 02:57 PM posted to microsoft.public.outlook.program_vba
85ascMcLaren
external usenet poster
 
Posts: 1
Default get outlook mailbox size from vba

Good info. I was hoping that there was a direct property to pull the mailbox
size from instead of traversing all the folders and items under the mailbox
object, but I guess not. I am not allowed to install any third party add-ins
on the client PCs, so I guess this is the only way?

In using this, I have found a problem. Encrypted emails. The size
property will not pull when it encounters an encrypted email. I error out
with a -2147217660 - Method 'Size' of object 'MailItem' failed.

Any suggestions on either of these questions? Is there a more direct way
of pulling a size from the mailbox or even the individual folders (inbox,
sent, etc) without traversing through each item and without installing any
other add-ins? If not - any way around the encrypted problem.... ??

Thanks,
Jason


"bobm" wrote:

Sub GetFolderSize()
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objOutlookToday = objInbox.Parent

For Each objSubFolder In objOutlookToday.Folders
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next
MsgBox "Total Size = " & lFolderSize
End Sub

Function GetSubFolderSize(objFolder As MAPIFolder) As Long
Dim lFolderSize As Long
Dim objSubFolder As MAPIFolder

For Each objItem In objFolder.Items
lFolderSize = lFolderSize + objItem.Size
Next

' process all the subfolders of this folder
For Each objSubFolder In objFolder.Folders
'Do something with objFolder
lFolderSize = lFolderSize + GetSubFolderSize(objSubFolder)
Next

GetSubFolderSize = lFolderSize
Set objFolder = Nothing
Set objItem = Nothing
End Function

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mailbox size Glikogen Outlook - General Queries 1 December 6th 06 03:35 PM
Outlook Web Access - Mailbox Size Question swwalsh Outlook - Installation 1 November 24th 06 05:44 PM
help w/mailbox size limit sunrosejenn Outlook - Calandaring 1 May 10th 06 01:56 PM
Exchange Mailbox server prohibit from sending when reach mailbox size limit Milly Staples [MVP - Outlook] Outlook - General Queries 1 February 24th 06 06:41 PM
If I use OMA can I verify the size of my mailbox Jay Outlook - General Queries 0 January 20th 06 09:44 AM


All times are GMT +1. The time now is 05:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.