Outlook output to array -> Excel & re-format

Status
Not open for further replies.

Dr. Demento

Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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>
 

Dr. Demento

Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
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
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
A Outlook Reminders not populating for certain events Using Outlook 2
O Moving "tasks" to inbox in Outlook 2016 Using Outlook 1
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
e_a_g_l_e_p_i Can emails from Gmail be deleted when they are downloaded to Outlook 2010 Using Outlook 1
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
Z Remove GMAIL IMAP account from Outlook 2016 Using Outlook 2
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 4
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
H Outlook 2019 intermittent search results Using Outlook 0
hstein POP3 latest Outlook Using Outlook 0
V Outlook 2003 and Windows 11 Using Outlook 4
J How to import many msg into different public folders in Outlook Outlook VBA and Custom Forms 7
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
A Reminder duplication Outlook and Outlook.com Using Outlook.com accounts in Outlook 5
F Moving Outlook to new PC Using Outlook 0
mll persistently customise columns in outlook advanced search Using Outlook 3
Ken Pascoe Outlook Categories Quick List Using Outlook 0
M All fonts in Outlook emails display with exaggerated character spacing Using Outlook 3
talla Can't open Outlook Item. Using Outlook 0
C Can't Locate an Unread Message in my Outlook view pane Using Outlook 0
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
P Importing other e-mail accounts into Outlook Using Outlook 1
J Read Outlook Form fields Outlook VBA and Custom Forms 3
B Inconsistent handling of message read/unread status by Outlook Using Outlook 3
R Rogue Outlook Rule ? Using Outlook 2
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
F Wishlist Outlook suddenly began synchronizing deleted items every time I delete a single email. Using Outlook 2
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
K Outlook 2019 Randomly Disconnecting from Gmail Servers Using Outlook 8
P Outlook calendar and contacts sync problem-outlook disconnects Using Outlook.com accounts in Outlook 2
HarvMan Toggle between calendar and email in Outlook 365 Using Outlook 12
V Outlook error 500 Using Outlook 2
F Email being marked as Spam by Gmail and not being visible in Outlook Using Outlook 5
S Mac Outlook 365 Questions Using Outlook 1
M Outlook calendar is missing Using Outlook 2
G Save and Rename Outlook Email Attachments Outlook VBA and Custom Forms 0
G Trigger script without restaring outlook Outlook VBA and Custom Forms 7
T Have you written an articles about Outlook? Using Outlook 3
V Compound IF, OR, AND in Outlook form Outlook VBA and Custom Forms 4
A Any way to make Outlook Calendar invitations look right to Gmail/Google Calendar users? Using Outlook 3
R Outlook 365 update sets delete from server flag Using Outlook 1
M How to setup outlook after importing old account information - Entering email account info creates with "(1)" after the account! Using Outlook 1
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
bhamberg Shortcuts in Folder Pane (Outlook 2016) Using Outlook 19
I Button PDF in Outlook Contact custom form Outlook VBA and Custom Forms 1
G VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1

Similar threads

Top