+ Reply to Thread
Results 1 to 26 of 26

Capture Outlook body fields and copy to excel

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Capture Outlook body fields and copy to excel

    Hi Forum Members,
    Good day to you all.
    I have a folder in outlook where all the email messages from the other team will fall in to that folder. i want the VBA code that capture all the messages one by one in excel sheet.
    The first slide is sample email message with the fields with column order number.
    The second slide, the capture results should come same as like the table to the excel sheet. I have attached sample sheets for your reference.
    I hope my question is clear to understand.
    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    You can start with loop through the emails - search for how-to-parse-outlook-emails-and-show-in-excel-worksheet-using-vba

    To access a specific folder
    Please Login or Register  to view this content.
    I would load the message body as HTML into an HTML document object and then find your data by parsing it.
    search for parse-html-in-excel-vba

    If you have any issues, post your code and what/where the problem is and I'm sure someone can help you out.

  3. #3
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Dear Gurus,
    I Got the basic code, but it read/capture basic elements in the email not the Body fields. The code below, can you tweak the code for my actual question. Thanks
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    Save one of the emails you'd like parsed to a file and upload it, so I can see the actual email body.

  5. #5
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Hi jdelano, it is in attached Zip file. sample outlook body fileds.JPGsample excel columns.JPG
    Last edited by farhanahamed; 02-15-2024 at 06:30 AM.

  6. #6
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    That is a powerpoint file, I'd like to see an actual email to see which html elements are used in it.

  7. #7
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Can you please check the zip file, i have attached the email message
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    Hmm this one is blank for some reason
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    My apologies. My organization do allow me to send any mail attachments outside the organization.
    Can you try this attachment if not opening, please tell me find the outlook elements
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    okay, thanks.

    EDIT: So, this is what I mean when I say the email HTML needs to be parsed.
    I will create some code pulling out some of the items from the HTML and then you can use that to get the rest of what you need. I'll edit this again in little bit.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by jdelano; 02-15-2024 at 09:35 AM.

  11. #11
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Hi Jdelano, I hope you are working on my request, please let me know if you have any queries. Thanks in advance

  12. #12
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    So here is some code, you can delete some of the commented lines to clean it up,
    I just wanted to show that as you go through the process of creating some code, it is good to be aware that you don't repeat the same code over and over.

    I stopped it and created a new function to do the repeated code for me and then just call that as many times as needed. I hope that makes sense.

    Please Login or Register  to view this content.
    To make the code cleaner, you can make a separate sub procedure to write to the sheet, just make the variables that hold the extracted data module scoped.
    Just move the DIM statements for them to the very top of the sheet1 module so that both the ParseHTML procedure and a new WriteToSheet procedure can access them
    Attached Images Attached Images

  13. #13
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Hi Jdelano,
    sorry for delay in my response. I am not welll, now much better.

    Can you please share me the sample file with code with button, where i can execute the code? coz i cannot run the code with private sub procedure.

  14. #14
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    Here you are

  15. #15
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    For some reason i cannot run the 'ParseHtml' Private procedure code, what should i do? can you help me.
    I am getting- 'user defined type not defined' error

  16. #16
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    Quote Originally Posted by farhanahamed View Post
    For some reason i cannot run the 'ParseHtml' Private procedure code, what should i do? can you help me.
    I am getting- 'user defined type not defined' error
    Make sure that you have a reference to Microsoft Outlook (Tools > References > Microsoft Outlook ## Object Library) maybe you don't have the same version.

  17. #17
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    I have modified your code based on my actual requirement, it seems to be not working. Is it possible for you to share the full code in sub Procedure i new module,
    The below pull all the default elements and also 'Fedx ID' in Body
    Please Login or Register  to view this content.
    Last edited by farhanahamed; 02-20-2024 at 09:31 AM. Reason: added code and picture

  18. #18
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    When you say it isn't working, what exactly isn't working? Is FedEx ID is not parsed out?
    Please Login or Register  to view this content.
    , you need to use a lowercase p, when using MSHTML you must use the same case at the actual HTML element. You will notice in my examples they are all lowercase.

    "The getElementsByTagName method in MSHTML (Microsoft HTML Object Library) is case-sensitive when searching for HTML elements."

  19. #19
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    jdelano,
    even i have changed to 'p' in the code, the Fedx Id is not parsed out. I tried to parse only fedx id by adding code for Fedx id along with my old code.
    can you provide me the straight forward macro, please?

  20. #20
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    Wha is the value of HeaderHTMLTable?

  21. #21
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    As per the above screen shot, the value is 'Lunux-27760-CISCO'

  22. #22
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    It would help to see the actual HTML that the variable HeaderHTMLTable contains to see why selecting the paragraph child element fails.

  23. #23
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    I do not understand, So you can not able to solve the problem or you cannot give the exact code what I am looking for?

  24. #24
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    99

    Re: Capture Outlook body fields and copy to excel

    You don't understand the question of posting the value of a variable?
    Also, I am helping out of kindness, please understand that.

  25. #25
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    I Know that, you guys helping us. Saviors.
    What is wrong with the code? Can you correct the code, can you please include the basic code with Body fields and Table. Thanks in advance

  26. #26
    Registered User
    Join Date
    02-22-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2016
    Posts
    35

    Re: Capture Outlook body fields and copy to excel

    Hi Jdelano, Why no reply, can you support for this VBA request, please?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy and paste Excel range as picture into Outlook email body using excel vba
    By ExcelDoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2016, 09:29 PM
  2. copy the content of the email body from outlook to excel sheet
    By Megatronixs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2014, 03:25 AM
  3. Capture data from access form into outlook body message?
    By ciapul12 in forum Access Tables & Databases
    Replies: 2
    Last Post: 05-18-2014, 07:48 AM
  4. [SOLVED] Copy URL from Excel to Outlook body
    By Southernw2002 in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 05-17-2014, 06:26 PM
  5. Macro to copy charts and data from excel to outlook body
    By aspirant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2013, 03:51 AM
  6. [SOLVED] Copy hyperlink from outlook email body and export to excel
    By addytiger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2012, 03:17 PM
  7. Copy Subject and Body from Outlook to Excel
    By ccstorey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2010, 11:54 AM

Tags for this Thread

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