• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Resize images in an Outlook email

Slipstick Systems

› Developer › Code Samples › Resize images in an Outlook email

Last reviewed on August 6, 2024     7 Comments

Applies to: Outlook (classic), Outlook 2010, Outlook 365 (Win)

For other formatting macros, see Format Images in Outlook Email and Use Word Macro to Apply Formatting to Email

A user needed to resize images in incoming email.

A few days earlier another user posted a sample macro he needed help with; his macro resized images. I put bits of his macro together with my Format Selected Text macro to resize selected images in a message.

To use this macro, you need to open the message and enable Editing.

To test the macro, select a message containing large images and press Ctrl+C to copy the message then press Ctrl+V several times to make copies of the message, so you have plenty of messages to work with as you determine the best size for your needs.

  1. Open the message.
  2. On the opened message's ribbon or menus: Go to Actions, Edit Message (Actions is in the Move section of the ribbon)
    enable editing on the message
  3. Select the images(s) or entire message.
  4. Run the macro.

This screenshot shows the original image size and the size after running the macro, with the picSize value set to 13:
original and resized images

The picture size (in CM) is set in this line:
picSize = 13

You'll need to set a reference to the Word Object Model in the VB Editor's Tools > References.

 Public Sub ResizeImagesReceivedMail()
    Dim objItem As Object
    Dim objInsp As Outlook.Inspector
    
    ' Add reference to Word library
    ' in VBA Editor, Tools, References
    Dim objWord As Word.Application
    Dim objDoc As Word.Document
    Dim objSel As Word.Selection
    On Error Resume Next

Dim targetHeight As Integer
Dim oShp As Shape
Dim oILShp As InlineShape
Dim picSize As Variant

' make all images (both inline and floating)
' 13 cm wide while preserving aspect ratio
picSize = 13
   
'Reference the current Outlook item
    Set objItem = Application.ActiveInspector.CurrentItem
    If Not objItem Is Nothing Then
        If objItem.Class = olMail Then
            Set objInsp = objItem.GetInspector
            If objInsp.EditorType = olEditorWord Then
                Set objDoc = objInsp.WordEditor
                Set objWord = objDoc.Application
                Set objSel = objWord.Selection

       With objSel
       ' Formatting code goes here
       
        For Each oShp In objSel.ShapeRange
        With oShp
        .LockAspectRatio = msoTrue
        .Height = AspectHt(.Width, .Height, CentimetersToPoints(picSize))
        .Width = CentimetersToPoints(picSize)
        End With
        Next
        For Each oILShp In objSel.InlineShapes
        With oILShp
        .LockAspectRatio = msoTrue
        .Height = AspectHt(.Width, .Height, CentimetersToPoints(picSize))
        .Width = CentimetersToPoints(picSize)
        End With
        Next 

       End With

            End If
        End If
    End If
    
    Set objItem = Nothing
    Set objWord = Nothing
    Set objSel = Nothing
    Set objInsp = Nothing
End Sub

Private Function AspectHt(ByVal origWd As Long, ByVal origHt As Long, ByVal newWd As Long) As Long
If origWd <> 0 Then
AspectHt = (CSng(origHt) / CSng(origWd)) * newWd
Else
AspectHt = 0
End If
End Function

How to use the macros on this page

First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.

To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

The macros on this page should be placed in a module.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

Set a reference to other Object Libraries
If you receive a "User-defined type not defined" error, you need to set a reference to another object library.

  1. Go to Tools, References menu.
  2. Locate the object library in the list and add a check mark to it. (Word and Excel object libraries version numbers will match Outlook's version number.)
    Reference the Word object model in Outlook's VBA Editor

More information as well as screenshots are at How to use the VBA Editor

More Information

resized images in Word sample posted in Answers forum by Word MVP Jay Freeman.

Resize images in an Outlook email was last modified: August 6th, 2024 by Diane Poremsky

Related Posts:

  • Format Images in Outlook Email
  • Use Word Macro to Apply Formatting to Email
  • Merge to email using only Outlook
  • Insert Emoji using VBA

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.

Subscribe
Notify of
7 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Jeff Borden
March 17, 2023 12:59 pm

I use screen clips a lot, and paste those into emails... the sizes are all over the place, and often way too big thanks to my 4K monitors...

Could this script be modified so that whenever I paste an image into an email, it automatically runs and resizes the image to a standardized specified width and/or scale?

0
0
Reply
Diane Poremsky
Author
Reply to  Jeff Borden
March 18, 2023 12:40 am

It should work... but is noy automatic. I'll take a look and see if it can be automated.

0
0
Reply
Jeff Borden
Reply to  Diane Poremsky
March 18, 2023 10:38 am

Thanks Diane,

It does work to resize the selected image (or multiples at once) after I've pasted... so that's certainly helpful.

Do you know if there is an event trigger that could run the macro on an image when I hit paste?

0
0
Reply
Diane Poremsky
Author
Reply to  Jeff Borden
March 18, 2023 11:07 am

I need to check on the trigger to see if it can be automated.

0
0
Reply
James Martin
September 17, 2022 11:02 am

This is the image compression macro I I created for Word. Not sure if it can easily be used in Outlook., The menus flicker a lot, as not directly codeable in VBA, and MSO, and SendKeys methods had to be used. I have a copy of this on the QAT in Word for 96ppi compression also. Took 10 months to get this to work! Easy when you see the code, so obvious, a bit frustrating that not all menus are directly codeable. List of MSO actions via dash&down chevron, above the Ribbon, via more commands, and All Commands...

Sub MacroC_28_06_2022()
'SOURCE: jam61mar@gmail.com
'150ppi
Word.Application.ScreenUpdating = False
If Word.Application.Documents.Count = 0 Then
Exit Sub
End If
Dim oIlS As inlineshape
If Word.ActiveDocument.Inlineshapes.Count > 0 Then
Word.ActiveDocument.Inlineshapes(1).Select
VBA.SendKeys "%W{ENTER}", True
Application.Commandbars.ExecuteMso ("PicturesCompress")
DoEvents '''28/06/2022 Add SendKeys for a 2nd time each time used to undo toggling off the NumLock
VBA.SendKeys "%W{ENTER}", True
Application.Commandbars.ExecuteMso ("PicturesCompress")
For i = 2 To Word.ActiveDocument.Inlineshapes.Count
If Word.ActiveDocument.Inlineshapes.Count > 1 Then
Word.ActiveDocument.Inlineshapes(i).Select
VBA.SendKeys "%W{ENTER}", True
Application.Commandbars.ExecuteMso ("PicturesCompress")
DoEvents '''2nd running to toggle numlock back on
VBA.SendKeys "%W{ENTER}", True
Application.Commandbars.ExecuteMso ("PicturesCompress")
End If
Next i
Word.Application.ScreenUpdating = True
End Sub

0
0
Reply
James Martin
September 4, 2021 6:18 pm

By accident I exploit a formatting quirk that could simplify this. I have been manually uploading 30 to 50 customer emails a day to a Council Account system for a few years. I have been researching automation such as Office 365 Flows and tested RegEx via Plumsail so with our IT Dept it should be possible to bounce back customer emails if they don't have the application number at the start of the Subject (and NI Number and date of birth in Email Body, and a match to the sender email). If sent correctly a text version of the email could be automatically added to the account with a bounce back acknowledgement with the queue number [original email kept for periodic customer reviews]. Anyway I am now creating a suite of Macos to simplify my job and to help others to do this, which is long winded - The Macos are with the help of this site: Save Outlook Item as text (with header and attachments list by default), docx with header (and attachments list), Rotate one image selected in docx, Rotate all images in docx [loads of customer emails have embedded images now from mobile uploads with no attachment… Read more »

Last edited 4 years ago by James Martin
0
0
Reply
DIMGI
May 31, 2019 6:24 am

Hello,
Could you please help me with code for formatting a picture frame to 1.5 pt + color = black?

And doing this while composing new e-mail.

Thanks in advance

0
0
Reply

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

Latest EMO: Vol. 30 Issue 38

Subscribe to Exchange Messaging Outlook






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?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • OUTLOOK.EXE continues running after you exit Outlook
  • Reset the New Outlook Profile
  • How to Remove the Primary Account from Outlook
  • Move an Outlook Personal Folders .pst File
  • How to Hide or Delete Outlook's Default Folders
  • Adjusting Outlook's Zoom Setting in Email
  • Disable "Always ask before opening" Dialog
  • This operation has been cancelled due to restrictions
  • Removing Suggested Accounts in New Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
Ajax spinner

Recent Bugs List

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

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

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

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

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

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

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

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

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

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

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment