Re: Copying body text from email to word doc



Paul,

The sub below will look in a subfolder of the Inbox named "Jokes" and
extract those messages received since the start of the current day and type
the bodies of those messages into the current active document with a new
paragraph started between each text body. If your folder of interest is at
the same level as the Inbox rather than being a subfolder, you will need a
slight modification. Note that when you run this subroutine, you will get a
security warning asking for permission to let the routine extract info from
Outlook for a period of 1 minute (or you can select a longer time period)

___________________________________

Sub CollectMsgBodies()
Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolderIN = objNamespace.GetDefaultFolder(olFolderInbox)
Set objFolder = objFolderIN.Folders("Jokes")

dtmTargetDate = Date

Set colItems = objFolder.Items
Set colFilteredItems = colItems.Restrict("[ReceivedTime] > '" &
dtmTargetDate & "'")


For I = 1 To colFilteredItems.Count
Selection.TypeText colFilteredItems(I).Body
Selection.TypeParagraph
Next I

End Sub
__________________________________

Steve



"Paul" <paul@xxxxxxxxxxxxxxxxxxx> wrote in message
news:%23kdjfZmGIHA.1212@xxxxxxxxxxxxxxxxxxxxxxx
Hi

I am trying to resuscitate some lost code someone wrote a few years back.

Basically, a colleague receives between 50 and 250 emails with specific
information in them which all go (or are copied) into a specific outlook
folder. I need to be able to extract the body text (only) of all messages
in this folder received each day and copy this text into one word document
for the day

Can anyone help or point me in the right direction?

many thanks in advance

Paul

--
Paul at preeve dot plus dot com



.



Relevant Pages

  • Re: How to parse a email with attachment- Miyahn please help
    ... WS.AppActivate "Extract Notes Attached Files" ... Sub SetFolder ... BFolder = FS.BuildPath ... Extract all attachments from the specified mail folder. ...
    (microsoft.public.scripting.vbscript)
  • Re: Populate a listbox with folder names
    ... why not use the "Browse for folder" dialog ... > Private Sub Form_Open ... Dim FSO As Scripting.FileSystemObject ... Dim SubFolder As Scripting.Folder ...
    (microsoft.public.access.formscoding)
  • Re: copy text files only from all subfolders within a folder to a
    ... Sub AllFolders (Folder) ... For Each SubFolder in Folder.Subfolders ... Function EnumFolder(ByVal vFolder) ...
    (microsoft.public.scripting.vbscript)
  • Re: Folder enumeration
    ... creating a variable to count the folder ... Sub ShowSubFolders ... WScript.Echo Depth & vbTab & subfolder ... I am trying to write a script to enumerate folders that will allow me ...
    (microsoft.public.scripting.vbscript)
  • Re: Folder enumeration
    ... creating a variable to count the folder ... Sub ShowSubFolders ... WScript.Echo Depth & vbTab & subfolder ... I am trying to write a script to enumerate folders that will allow me ...
    (microsoft.public.scripting.vbscript)