Checking Message Size

Question:
Is there a way to write a script at the Outlook client that will make sure the message size—including an attachment—doesn’t exceed our limit as soon as the message composition is started?

Answer:
Yes, you can do that with VB by using the ItemSend event like this:

Private Sub Application_ItemSend(ByVal Item
As_ Object, Cancel As Boolean) Item.Save If Item.Size < 100000 Then MsgBox Item.Size & " is too large a_ message." Cancel = True End IfEnd Sub

This uses the item.size property to determine the size of the message item (attachment and all) and compares it to an arbitrary value (in bytes). In this case, I've set the checkpoint to be 100,000 bytes (roughly 100K) but you could set it anywhere you like. It then displays a message box showing the user the message's size (in bytes) and letting them know it's too large. It then cancels their send, leaving the compose message screen up for them to modify their message.

If their message is under that size value, the message will be sent with no interaction with the user at all.

Note that you do need the item.save method before the item.size, because before the item is saved the size will always equal zero so your comparison always will fail and every message will be sent.

To distribute that to your users I'd compile it into a COM Add-in and distribute that—but you could just distribute the VBA project as well (if your users don't have any preexisting customizations that would be overwritten by this new project).

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may