Consulting

Results 1 to 2 of 2

Thread: folder containing Msg file, Extracting senders name , subject on a txt file

  1. #1

    folder containing Msg file, Extracting senders name , subject on a txt file

    Hello ,

    i have a folder that is saved on my computer that contains msg files. These were dragged and dropped from an outlook folders . At the moment i can click into the file and they open as messages.

    What i like to be able to do is be able to search them better. The message name is the only thing i can search for just now. I like to be able to have some of the information that is contained within this msg files onto a spreadsheet.

    i was wondeirng if its possible to take the senders name , subject name , attachment names and data sent and write this to a txt file or excel file..

    i have no experience of writing vba in Outlook , but was wondering if this is possible thanks for you time

  2. #2
    but was wondering if this is possible
    quite possible

    loop through all .msg files in some folder, open in outlook, read properties to excel or whatever, close, next message

    mypath = "c:\temp\"    ' change to suit, note trailing \
    set xl = createobject("excel.application")
    set sht = xl.workbooks.open(somepath\excelfile.xls).sheets("sheet1")  ' change filepath and sheet to suit
    rw = sht.cells(sht.rows.count, 1).end(xlup).row + 1    ' get next empty row
    mymsg = dir(mypath & "*.msg")
    do while len(mymsg) > 0 
      Set mi = Application.CreateItemFromTemplate(mypath & mymsg)
      sht.cells(rw, 1) = mi.subject
      sht.cells(rw, 2) = mi.sendername
      sht.cells(rw, 3) = mi.senton
      ' etc. etc for other properties
      mi.close oldiscard
      mymsg = dir
      rw = rw + 1
    loop
    sht.parent.save
    xl.quit
    the example above is to be coded in outlook, with a few changes, could be coded in excel
    i did not test the code in whole, so it may contain some errors or typos

Posting Permissions

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