Rather hard macro...

Joined
Mar 22, 2011
Messages
1
Reaction score
0
I need a macro that does some stuff which might be impossible (I don't know, so that's why I'm asking!)

Basically I want it to open all the emails in a given folder, copy all their contents, and insert them into an excel file. Possible? Not possible?

If it's possible please give me the code. Thanks.
 
Joined
Mar 15, 2011
Messages
19
Reaction score
0
absoluteley. i just finished a project that does something similar. Mine has to parse the email body, pull out very specific details, and store them in an access database.

the most annoying thing i found was trying to get the EntryID for a given named folder. this function should help (although i'm hoping someone will wade in and say "molly pet, theres a much easier way to do that")

Code:
Function fGetChildFolderByName(objParentFolder As Folder, strFolderName As String) As Folder
Dim intCount As Integer, intFolders As Integer, objOutput As Folder
    
    intFolders = objParentFolder.Folders.Count

    For intCount = 1 To intFolders
        If objParentFolder.Folders.Item(intCount).Name = strFolderName Then
            Set objOutput = Outlook.Session.GetFolderFromID(objParentFolder.Folders.Item(intCount).EntryID)
        End If
    Next intCount
Set fGetChildFolderByName = objOutput
End Function

you'll have to feed it the personal folders first, and repeat the process as many times as the destination folder is nested deep. see why i hope ther is a quicker way now?

then you'll need to create an excel object to create your file in. something like;

Code:
Dim appExcel

Set appExcel= Application.CreateObject("Excel.Application")

now, i could sit here for the next hour or so and write out the entire code for you, but I wouldn't dream of stealing the precious moment when handwritten code delivers. that moment is precious.
i've given you some good nudges, if things get a little tricky though, that doesnt mean i'm going to leave you completley in the dark man.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top