vba - Copy emails from my Sent Folder in Outlook 2010 to an Excel file -


i need make record of emails i've sent on last couple years, , include sent to, date, , body of message. exporting outlook not carry date, , reason access won't import data outlook on company computers

i came across macro export outlook excel, of information need, pulls inbox: http://officetricks.com/outlook-email-download-to-excel/

i searched office vba website commands make export sent items folder instead of inbox, kept getting run-time error 438 "object doesn't support property or method" @ receivedbydate , cc lines (under command below). happens sent emails. tried moving them separate folder , inbox, macro fails when reads emails sent me.

sub mail_to_excel() ' ' mail_to_excel macro ' copies emails outlook excel file ' add tools->references->"microsoft outlook nn.n object library" ' nn.n varies per our outlook installation     dim folder outlook.mapifolder     dim irow integer, orow integer     dim mailboxname string, pst_folder_name  string      'mailbox or pst main folder name (as how displayed in outlook session)     mailboxname = "myname@company.com"      'mailbox folder or pst folder name (as how displayed in outlook session)     pst_folder_name = "sent items"      set folder = outlook.session.folders(mailboxname).folders(pst_folder_name)     if folder = ""         msgbox "invalid data in input"         goto end_lbl1:     end if      'read through each mail , export details excel email archival     thisworkbook.sheets(1).activate     folder.items.sort "received"      'insert column headers     thisworkbook.sheets(1).cells(1, 1) = "sent to"     thisworkbook.sheets(1).cells(1, 2) = "copied"     thisworkbook.sheets(1).cells(1, 3) = "subject"     thisworkbook.sheets(1).cells(1, 4) = "date"     thisworkbook.sheets(1).cells(1, 5) = "size"     thisworkbook.sheets(1).cells(1, 6) = "body"      'insert mail data     irow = 1 5     'folder.items.count         orow = irow + 1         thisworkbook.sheets(1).cells(orow, 1).select         thisworkbook.sheets(1).cells(orow, 1) = folder.items.item(irow).receivedbyname         thisworkbook.sheets(1).cells(orow, 2) = folder.items.item(irow).cc         thisworkbook.sheets(1).cells(orow, 3) = folder.items.item(irow).subject         thisworkbook.sheets(1).cells(orow, 4) = folder.items.item(irow).receivedtime         thisworkbook.sheets(1).cells(orow, 5) = folder.items.item(irow).size         thisworkbook.sheets(1).cells(irow, 6) = folder.items.item(irow).body     next irow      msgbox "outlook mails extracted excel"  end_lbl1: end sub 

try senton https://msdn.microsoft.com/en-us/library/office/ff864408.aspx instead of receivedtime.

you may interested in discrepancy between two. mapi outlook object model mailitem.senton > mailitem.receivedtime, how possible?

some items in sent items folder not mailitems may not have .cc property.

you need test like

if item(irow).class = olmail 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -