• Outlook User
  • Exchange Admin
  • Office 365
  • Outlook Developer
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
    • Common Problems
    • Outlook BCM
    • Utilities & Addins
    • Video Tutorials
    • EMO Archives
    • Outlook Updates
    • Outlook Apps
    • Forums

Check Message Size Before Sending

Slipstick Systems

› Outlook › Email › Check Message Size Before Sending

Last reviewed on April 27, 2015     3 Comments

August 3, 2011 by Diane Poremsky 3 Comments

"Is there any way I can set up a warning (or possibly limit) on the size of file I can email? I'm guilty of accidentally sending 13mb files."

Sure, you can use VBA to warn you.

A very basic warning uses this simple code:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
     If Item.Attachments.Count > 0 Then
         ans = MsgBox("Is the attachment too big?", vbYesNo)
       If ans = vbYes Then Cancel = True
     End If
End Sub

This simple procedure checks for the presence of attachments and asks if the attachments are too large. While this is fine if you don't send a lot of attachments, it would be even better if you were alerted only when the message size was too large.

Better VBA

Outlook MVP Michael Bauer offers this procedure that checks for the presence of attachments and if any are found, it checks the message size. When the message exceeds the Max_item_size you configured, a warning dialog pops up.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
   If TypeOf Item Is Outlook.MailItem Then
      Cancel = Not (ConfirmBigAttachments(Item))
   End If
End Sub
 
Private Function ConfirmBigAttachments(oMail As Outlook.MailItem) As Boolean
' by Michael Bauer //www.vboffice.net 
 
Dim lSize As Long
Const MAX_ITEM_SIZE As Long = 1048576 ' in Bytes. This is 1 MB
Dim bSend As Boolean
 
bSend = True
    If oMail.Attachments.Count Then
       lSize = oMail.Size
      If lSize > MAX_ITEM_SIZE Then
bSend = (MsgBox("Item's size: " & lSize & " Byte. Cancel?", vbYesNo) = vbNo)
      End If
    End If
  ConfirmBigAttachments = bSend
End Function

How to Use

To use either of these code samples with Outlook, open the VBA editor (Alt+F11) then copy and paste the code into ThisOutlookSession. The max_item_size is set for 1 megabyte but can be changed to any number. Save it and every time you send a message, the ItemSend procedure will run.

If you need help converting megabytes to bytes, go to google and type "x megabyte in bytes" into the search field, where x is the number you need to convert.

More Information

Michael Bauer's E-Mail: Check item size before sending
How to use Outlook's VBA Editor

Check Message Size Before Sending was last modified: April 27th, 2015 by Diane Poremsky

Related Posts:

  • Use VBA to check Outlook's outgoing messages for attachments and cance
    Do you want to send an attachment?
  • A macro that checks the number of recipients on an outgoing Outlook me
    Check messages you send for number of recipients
  • Check for missing attachments before sending a message
  • Remove an Address from Reply All

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

3
Leave a Reply

2500
Photo and Image Files
 
 
 
Audio and Video Files
 
 
 
Other File Types
 
 
 
2500
Photo and Image Files
 
 
 
Audio and Video Files
 
 
 
Other File Types
 
 
 

  Subscribe  
newest oldest most voted
Notify of
Jonas Schelde
Jonas Schelde

Outlook.mailitem, doesn't work in outlook 2013

Vote Up00Vote Down Reply
January 15, 2015 11:38 am
Jonas Schelde
Jonas Schelde

This made it work instead: https://social.technet.microsoft.com/Forums/office/en-US/1e1b0724-3b9e-4149-ae5b-d01c43b51f42/attachment-warning-custom-vba-for-outlook-2010

Vote Up00Vote Down Reply
January 15, 2015 2:07 pm
Diane Poremsky
Diane Poremsky

It does, it works in all versions of Outlook. It won't work for meeting requests etc, but will work with actual email.

Vote Up00Vote Down Reply
January 21, 2015 12:35 am

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 24 Issue 3

Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Subscribe to Exchange Messaging Outlook






Our Sponsors

  • Popular
  • Latest
  • Week Month All
  • Adjusting Outlook's Zoom Setting in Email
  • The Signature or Stationery and Fonts button doesn't work
  • Security Certificate Warning in Microsoft Outlook
  • This operation has been cancelled due to restrictions
  • How to Remove the Primary Account from Outlook
  • Two Copies of Sent Messages in Outlook
  • iCloud error: Outlook isn't configured to have a default profile
  • Outlook's Rules and Alerts: Run a Script
  • Outlook is Not Recognized as the Default Email Client
  • Outlook and Gmail's Less Secure Apps Setting
  • Outlook.com: Manage Subscriptions
  • Group By Views don’t work in To-Do List
  • Category shortcuts don’t work
  • How to disable the Group By view in Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Change the Subject of an Incoming Message
  • Creating Signatures in Outlook
  • Scheduling a Recurring Message
  • OneNote is missing from Office 365 / 2019
  • Create Rules using PowerShell
Ajax spinner

Newest VBA Samples

Adjusting Outlook's Zoom Setting in Email

Move email items based on a list of email addresses

Remove prefix from Gmail meeting invitations

How to hide LinkedIn, Facebook, Google and other extra contact folders in Outlook.com

Use VBA to create a Mail Merge from Excel

Open multiple Outlook windows when Outlook starts

Set most frequently used Appointment Time Zones

How to change the From field on incoming messages

VBA: File messages by client code

Update Contact Area Codes

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in Outlook for Windows.

Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Better Outlook Reminders?
  • Coming Soon to Windows 10: Office 365 Search
  • Outlook Links Won’t Open In Windows 10
  • BCM Errors after Upgrading to Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook 2016 Top Issues

  • The Windows Store Outlook App
  • Emails are not shown in the People Pane (Fixed)
  • Calendars aren’t printing in color
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • BCM Errors after October 2017 Outlook Update
  • Excel Files Won’t Display in Reading Pane
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

Outlook-tips.net Samples

VBOffice.net samples

OutlookCode.com

SlovakTech.com

Outlook MVP David Lee

MSDN Outlook Dev Forum

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes
  • “Live” Group Calendar Tools

Convert to / from Outlook

  • Converting Messages and Calendar or
    Address books
  • Moving Outlook to a New Computer
  • Moving Outlook 2010 to a new Windows computer
  • Moving from Outlook Express to Outlook

Recover Deleted Items

  • Recover deleted messages from .pst files
  • Are Deleted Items gone forever in Outlook?

Outlook 2013 Absolute Beginner's Guide

Diane Poremsky [Outlook MVP]

Make a donation

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Outlook Suggestion Box (UserVoice)

Slipstick Support Services

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Sync & Share

Share Calendar & Contacts

Synchronize two machines

Sharing Calendar and Contacts over the Internet

More Tools and Utilities for Sharing Outlook Data

Access Folders in Other Users Mailboxes

View Shared Subfolders in an Exchange Mailbox

"Live" Group Calendar Tools

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Outlook BCM | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Advertise | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2019 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

You are going to send email to

Move Comment