Can this Macro be changed so it only pulls in the text body of the reply email from out look?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have this Macro that is brilliant and brings in all my email data from a folder in outlook into my excel sheet,

The only problem is this line,
"
"ws.Range("F" & r).Value = olMail.Body"

because people are replying to my email it brings in everything including my original email.
now i need to auto a check to see if they have replied yes or no which i can do but I need the text body to only be the reply not everything
is there any way we can check my macro so it only brings in the reply body text?

thanks
Tony
Heres my code:

VBA Code:
Sub ExtractEmailContent()
Dim olApp As Outlook.Application, olNs As Namespace, olFolder As MAPIFolder, _
olMail As MailItem, eFolder As folder, ws As Worksheet
Set ws = ActiveSheet
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")

Dim fldr As Outlook.MAPIFolder

Set fldr = olNs.GetDefaultFolder(olFolderInbox).Folders("Replys")
 r = 2
 
For Each olMail In fldr.Items

                    ws.Range("A" & r).Value = olMail.Subject
                    ws.Range("B" & r).Value = olMail.ReceivedTime
                    ws.Range("C" & r).Value = olMail.SenderName
                    ws.Range("D" & r).Value = olMail.cc
                    ws.Range("F" & r).Value = olMail.Body
                    ws.Range("E" & r).Value = olMail.SenderEmailAddress
                    r = r + 1

    Next

End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
The body is the body. If earlier emails are quoted they are part of the body, not some separate component. The only way to exclude them is to write code to parse the body and just extract the part you want. The problem with that is that there is no one standard way to quote earlier emails in a reply. If you are in an organization where everyone uses the same mail format it might be possible, if you provide a sample of an email.

BTW why did you make your entire post a quote?
 
Upvote 0
Solution
Thanks Jeff,
I think what i'm going to do is import all the data then split it once its in the excel sheet which should be quite easy.
Thanks for your help
Tony
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top