+ Reply to Thread
Results 1 to 4 of 4

VBA code to copy Outlook Messages to excel

  1. #1
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    VBA code to copy Outlook Messages to excel

    Hello - - I have a question that I don't know if it's possible. I'm looking to copy the content of emails coming from the same email address (about 5 to 10 per day) and paste them into an Excel file. The goal is to compare records counts...day to day to day...and then flag ones where the variance is plus or minus x number of records.

    The email body is very basic, 4 lines: Date, Filename, File size and Record Count.

    Here's an example of the message:

    Date: Thu 15 Sep 2011 09:01:09 AM EDT
    Filename: AUTO_C12345_20012356874.dat
    File size: 162887
    Record Count: 475


    Is there some starting code someone might have to share that would get me started?

    As I think of my question, I think I'm about to make it a bit more complicated. In addition of puting this data into a specific excel file, the excel file would be the same day after day, where the newest data is placed in the first empty row. The data elements of the email: Date, Filename, File Size and Record Count become headers, so I think theres some sort of transpose thing I would need to consider as well. The emails should also be from the same address, but the ones that are unopened and ignore the already opened emails. Again, any thoughts and/or suggestions would be great.

    Wasn't sure if should have marked it solved or not - - I moved on and tried something else. Basically I took the 4 lines from the email and pasted them into a spreadsheet - - from there I ran and recorded a series of steps like: text to columns, copy/paste special/transpose, moved cell values to final columns and rows, deleted empty rows, sorted the file by filename...etc. I put all my recorded code together and ran them all as one macro and it did what I needed. The only thing I do manually is copy the original email and paste it into this excel file. Then I run my code, then repeat. So it's fast enough for my situation.

    If anyone is interested, here is my code from Excel:

    Please Login or Register  to view this content.
    Last edited by Ironman; 09-15-2011 at 05:41 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA code to copy Outlook Messages to excel

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: VBA code to copy Outlook Messages to excel

    Hello snb....I get an error, out of range at

    sn(j-1,jj)=sp(jj)

    I'm sort of new to vba and I'm trying to determine what exactly what your code is doing.

    Thanks for the response!

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA code to copy Outlook Messages to excel

    Maybe you should use:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1