Outlook VBA Code to Check Mail Size
January 22, 2008 – 8:55 pm by JP
This code, run on the currently open mail item, will display a message box giving you the size of the email in kilobytes.
Sub CheckMailSize()
Dim CurrentMsg As Outlook.MailItem
On Error Resume Next
Set CurrentMsg = ActiveInspector.CurrentItem
On Error Goto 0
If (CurrentMsg Is Nothing) Or (TypeName(CurrentMsg) "MailItem") Then
MsgBox "Double-click on a message first."
Exit Sub
End If
MsgBox "This message is " & CurrentMsg.Size & " kb."
Set CurrentMsg = Nothing
End Sub
And here is an application-level event handler that does the same thing (if you don’t mind being interrupted every time you hit ‘Send’):
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeName(Item) = "MailItem" Then
Dim Msg As Outlook.MailItem
Set Msg = Item
MsgBox "This message is " & Msg.Size & " kb."
Set Msg = Nothing
End If
Enjoy,
JP
Print This Post
|
Email This Post
|
Subscribe to Posts Feed
|
Subscribe to Comments
Filed Under: Outlook, VBA
Tags: MailItem, Outlook, VBA









