Outlook output to array -> Excel & re-format

Status
Not open for further replies.

Dr. Demento

Member
OS Version(s)
  1. Windows
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
In using an awesome sub by Greg Thatcher (found here), it does a great job at extracting the information, but the output leaves much to be desired.

I'm wondering if someone could help in two ways:
1) point me the the direction where I could write the output first to an array (for speed/efficiency sake given that it extracts info about every email you own) and then to Excel; the more generic, the better as I'm wanting to alter multiple bits of his code to output to Excel rather than an Outlook email message.
2) the current format has information spread out all over the place. I would like the output to be set up like a table (with each row being a different email/item and each column being consistent - Subject, Last Modification Time, Message Class, etc). Again, a point in the right direction would be awesome.

Thanks much y'all.

I originally posted this thread here.
 
It looks like he is using one line per field - not sure it would be any better putting it in table format unless you use HTML.
To format it in tables, you'd need to use something like this and write it to an html message.
Report = Report & "<table><tr><th>Subject: </th><th>MessageClass:</th></tr>"
Report = Report & "<tr><td>" & rowValues(1) & "</td><td>"& rowValues(2) & &"</td></tr>"

After all the records are written, use report = report & "</table>"


But if you want it in Excel, I'd write it there directly. I have a macro here -http://www.slipstick.com/developer/code-samples/macro-export-outlook-fields-excel/ - that works on the selected messages and puts them in one message per line recordset format. It writes one record at a time which might not be any faster.

the macro at http://www.slipstick.com/developer/code-samples/working-items-folder-selected-items/ shows how to change from working with selected message to looping through all messages in the folder.

Use the code from Greg's that walks the folders and add the fields that you need:

<snipped>

Dim SubFolders As Outlook.Folders
Dim SubFolder As Outlook.Folder

Set SubFolders = CurrentFolder.Folders
For Each SubFolder In SubFolders

' loop through the messages writing to excel one line at a time
Set objItems = SubFolder.Items

For Each olItem In objItems

strColB = olItem.SenderName
strColC = olItem.SenderEmailAddress
strColD = olItem.Body
strColE = olItem.To
strColF = olItem.ReceivedTime


'write them in the excel sheet
xlSheet.Range("B" & rCount) = strColB
xlSheet.Range("c" & rCount) = strColC
xlSheet.Range("d" & rCount) = strColD
xlSheet.Range("e" & rCount) = strColE
xlSheet.Range("f" & rCount) = strColF
'Next row
rCount = rCount + 1

next ' message

Next SubFolder


<snipped>
 
Thanks so much, Diane! I will definitely look at those articles.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Android Outlook Doesn't Update PC Notification Changes Using Outlook 0
A How to open Excel file saved in Outlook folder? Outlook VBA and Custom Forms 4
D.Moore Outlook desktop client suggested searches question Using Outlook 13
Y Outlook 2016 (64-bit) Copy Local Cal. Events to Another Cal. with Modified Reminder time Using Outlook 2
T Outlook 2019 While connecting an IMAP account in "classic" Outlook 2024 I caused a massive duplication of emails on the server (death loop) Using Outlook 5
D Cannot logon to Outlook.com, or outlook on Mac, outlook not updating on ipad, iphone Using Outlook 1
J unable to get my new install of Outlook to display mailboxes in the single-line format. Using Outlook 1
D Legacy Microsoft Outlook for Mac Support will end in Oct 2025 Using Outlook 5
C Nasty Bug Lurking In Outlook For Years. The Trigger. Any Fix Or Workaround? Using Outlook 11
R Auto clicking Hyperlink in outlook Outlook VBA and Custom Forms 7
ughlook Open multiple contacts in NEW Outlook? Using Outlook 3
G Outlook translation feature is off Using Outlook 2
J Outlook 2010 does not let me put any account Using Outlook.com accounts in Outlook 3
P 3 of 5 PST files don't install from d:\outlook but only from D:\ Using Outlook 7
HarvMan January Windows 10 preview update force installs new Outlook Using Outlook 1
L Outlook 2010 - new installation on Windows 11 - aplzod32.dll is not a valid Add-in Using Outlook 12
J Outlook troubleshooting/logging - option grayed out Using Outlook 2
B Arrows missing from Outlook emails vertical scrollbar Using Outlook 0
G Outlook 2021 (New) doesn't respect default browser Using Outlook 9
B Outlook or iPhone turning tabs into spaces in Outlook Notes Using Outlook 1
P newly installed Office 365 includes OLD Outlook Using Outlook 6
R Outlook ribbon menu default? Using Outlook 7
H Spam email in Gmail not visible in Outlook Using Outlook 3
J How to transfer Win 10 Outlook to new Windows 11 pc? Using Outlook 16
J Renegade spam URL line displayed in old local Outlook 365 email title Using Outlook 3
G Reduce whitespace in Outlook desktop Contact Cards display Using Outlook 3
C Outlook classic via 365 Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
S Repair Outlook Using Outlook 8
V Outlook Form ListBox is not editable Outlook VBA and Custom Forms 2
F Outlook's contacts Using Outlook 1
D Outlook 2003 stopped dead Using Outlook 2
G Cannot receive emails from gmail account in Outlook 365 Using Outlook 1
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 8
P Outlook 2016 Working Offline Using Outlook 2
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
O Outlook 365 synchronisieren Exchange Server Administration 1
kburrows Outlook Classic - JPG files are corrupted when opened or saved Using Outlook 3
F Sync Outlook Calendar Using Outlook 0
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
C VBA in "New Outlook?" Using Outlook 0
D New Outlook with Business Basic Plans Using Outlook 0
D Outlook 2021 not working with Outlook 2003 installed Using Outlook 5
D Outlook 2003 stopped working - get they dialog box asking for username & Password Using Outlook 2
T Outlook 2021 hangs in close on taskbar occasionally Using Outlook 1
M Duplicate removal feature in Outlook 2021 is faulty Using Outlook 2
D.Moore Outlook COM addins source folder Using Outlook 12
P Removing Outlook 365 Account from Send/Receive Using Outlook 3
kburrows Outlook Automatically Merging Contacts Using Outlook 2
A Outlook 2016 Outlook 2016 vs. New Outlook Using Outlook 4

Similar threads

Back
Top