Print out ALL emails

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,179
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Hi all
I have a client that wants to print ALL EMails from his Inbox once each day.
He wants to do this from Excel and Outlook will be open at all times
Has anyone done anything like this.
I'd appreciate any code, or assistance that can be provided
I'd be more than happy to save to a folder, then print them from there....if that's easier
Regards
Michael
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

RickXL

MrExcel MVP
Joined
Sep 9, 2013
Messages
4,328
Hi,

This should be a good starting point.

You need to set up a reference to Microsoft Outlook 15.0 Object Library and place the code below into an Excel macro Module.

The macro goes to the InBox and loops round the items in there. It selects the mail items with a received date of today then it prints them.

Code:
' Requires Tools-->References-->Microsoft Outlook 15.0 Object Library
Sub PrintInbox()

    Dim olApp As Outlook.Application
    Dim olNs As Outlook.Namespace
    Dim olFldr As Outlook.MAPIFolder
    Dim olItem As Object
    Dim olMailItem As Outlook.MailItem
    
    Set olApp = CreateObject("Outlook.Application")
    Set olNs = olApp.GetNamespace("MAPI")
    Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
    
    For Each olItem In olFldr.Items
        If olItem.Class = olMail Then
            Set olMailItem = olItem
            If olMailItem.ReceivedTime > Date Then olMailItem.PrintOut
        End If
    Next olItem
    
End Sub
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,179
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Thanks
Really appreciate the response, I think this should do the trick.
Much appreciated....(y)
 

RickXL

MrExcel MVP
Joined
Sep 9, 2013
Messages
4,328
No problem.

I Googled email printing before I started just in case something was out there that I should know. All I got were lots of references involving Hillary Clinton!
This is not for Hillary, is it? :)

Regards,
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,179
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
:LOL:..:LOL:
I can just imagine the Secret Service saying to each other....."eh boys, how we gonna do this ???.....Dunno lets contact Mr excel"....:ROFLMAO::ROFLMAO:
 

Watch MrExcel Video

Forum statistics

Threads
1,130,111
Messages
5,640,156
Members
417,127
Latest member
shakilk

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top