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
G LinkedIn tab missing in Outlook 365 (but working in OWA) Using Outlook 0
J Outlook forgets "not junk" marking Using Outlook 0
KurtLass Opening Graphics Attachments in Outlook 2021 Using Outlook 0
P now on office 365 but getting error messages about missing Outlook 2013 cache folders Using Outlook 2
B Outlook config download Outlook VBA and Custom Forms 1
M Short term workaround for when Outlook searching stopped functioning Using Outlook 0
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
L Synch Outlook 365 calendar with iPhone Using Outlook 0
W Can vba(for outlook) do these 2 things or not? Outlook VBA and Custom Forms 2
S Outlook 2016 and Acrobat PDFMaker Office COM Addin Using Outlook 0
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
M Outlook 365 Rename Outlook Priority Using Outlook 3
R Outlook 2019 accesses POP3 but says its offline (because of IMAP servers?) Using Outlook 0
R Outlook Working off line Using Outlook 0
D Outlook 365 Custom forms field limit? Outlook VBA and Custom Forms 4
W Outlook 2016 MSI - Possible to make work with O365 modern Auth & Win7? Using Outlook 4
T Outlook roaming signatures Using Outlook 4
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
J Outlook search bar in Office 2021 Professional Using Outlook 1
J PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
C How to fix outlook continuing to prompt fo an Exchange password Using Outlook 0
C Outlook doesn't feel reliable, anymore Using Outlook 5
J Outlook 2016 Trying to get Outlook 2016 to work with Office 365 Using Outlook 0
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
U Outlook not responding when trying to print Emails Using Outlook 5
O How to sync (one way) contacts between two Outlook (exchange) accounts? Using Outlook 0
S Sync Outlook (2021) tasks with Microsoft To Do Using Outlook 1
L Duplicate calendar entries in Outlook 365 Using Outlook 4
V Outlook 2021 Can anyone explain why my Outlook views keep changing?! Using Outlook 2
AlphonseG Outlook 365 Outlook Crashes on setting SaveSentMessageFolder Outlook VBA and Custom Forms 5
S Outlook 2021 How to customize colors Outlook 2021 & Office 2021 on PC Using Outlook 2
D Outlook 2007 Recovering E-Mails Using Outlook 0
G Stop Outlook 365 adding meetings to calendar Using Outlook 2
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
Albert McCann Outlook 2021 Outlook Display of HTML Email from two senders is glitchy Using Outlook 0
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 1
K Outlook for Mac problems Using Outlook 0
D Outlook app 2021 & iCloud PST issues Using Outlook 2
M c# vsto Outlook.ApplicationEvents_11_NewMailEx Outlook VBA and Custom Forms 1
J Event/Meeting in Outlook Does Not Align with SharePoint Calendar Using Outlook 5
Christopher M Is it me, or is Outlook 365 BUGGY? Using Outlook 3
U Outlook on the iPhone cannot approve filtered Emails Using Outlook 0
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
K Outlook 365 After migrating to Outlook 365, some contacts display in emails with prefixes Using Outlook 0
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0

Similar threads

Top