Consulting

Results 1 to 4 of 4

Thread: Macro to extract data form email

  1. #1
    VBAX Newbie
    Joined
    Aug 2016
    Posts
    2
    Location

    Macro to extract data form email

    Dear Members.
    I need some help with this macro. The macro was made by another person that I paid but it make different. I need some one to look at it and let me know what I need to do. I am new in VB. I will execute this macro via Outlook every one hour. It will look to the inbox for new specific emails as per Outlook rule, with a data I need as you can see on the macro. It writing a header on a CSV file for the single email that is processing now and we need to make a change to avoid duplicate headers and write the data in individual lines as is describe on the macro.

    My only problem is that the macro is only reading the last email and I need to read all the new unread email every time that I execute it. The macro is saving the data on a CSV in a folder that I move as soon I process the data in the file.

    Can some help my. Here is the Macro. The attachment link is not working.
    Macro.docx

  2. #2
    You paid someone to create a macro for you, then apparently messed it around (as I am sure a programmer wouldn't have left it like that) and now you want someone to fix it for free and without access to the materials it is supposed to process?

    Assuming the messed around macro actually worksd, why execute the macro every hour manually? Why not simply run the macro from a script associated with a rule to identify the incoming messages and process them as they arrive, as was originally intended. Take a look at http://www.gmayor.com/extract_data_from_email.htm which explains how that would work.

    I am not sure of the relevance of the CSV vis-a-vis the worksheet, but if you want to add the header row only to a new CSV file, then test for a new file e.g.

    Dim fso As Object
        Dim bNew As Boolean
        Set fso = CreateObject("Scripting.FileSystemObject")
        If Not fso.FileExists(CSVPATH) Then bNew = True
        Open CSVPATH For Output As #1
        If bNew Then
            Print #1, "AppName,Store,User e-mail,Work Order,Priority,Store Number,Addreess,City,Name,Phone No,Detailed Description of Services Provided Including Cause of Possible Service Issue:"
        End If
        Print #1, srm
        Close #1
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Aug 2016
    Posts
    2
    Location
    Quote Originally Posted by gmayor View Post
    You paid someone to create a macro for you, then apparently messed it around (as I am sure a programmer wouldn't have left it like that) and now you want someone to fix it for free and without access to the materials it is supposed to process?

    Assuming the messed around macro actually worksd, why execute the macro every hour manually? Why not simply run the macro from a script associated with a rule to identify the incoming messages and process them as they arrive, as was originally intended. Take a look at which explains how that would work.

    I am not sure of the relevance of the CSV vis-a-vis the worksheet, but if you want to add the header row only to a new CSV file, then test for a new file e.g.

    Dim fso As Object
        Dim bNew As Boolean
        Set fso = CreateObject("Scripting.FileSystemObject")
        If Not fso.FileExists(CSVPATH) Then bNew = True
        Open CSVPATH For Output As #1
        If bNew Then
            Print #1, "AppName,Store,User e-mail,Work Order,Priority,Store Number,Addreess,City,Name,Phone No,Detailed Description of Services Provided Including Cause of Possible Service Issue:"
        End If
        Print #1, srm
        Close #1
    Dear Sir


    First of all let me say thanks for taking your time, Yes I did pay for it and No I don't looking for free. I just looking for some help on this to make it work and I WILL BE GLAD to pay for the work on any member that can fix it.

    Yes the macro was working but they make some changes and right now is not working. I do have the rule to run it a they arrive and a macro to turn Outlook on and to kill it. The reason is that the data that I am getting from the email is use to feed another application and the only accept CSV files and the program need an specific header to process it.

    I will we glad to work thing out with you to make it work, For what I saw in your site I am sure you can. SO please let me know what you can do to make it happen. I can gave you all the information that you need including access to the PC.

    Once again thanks for your time

    Luis

    Here is the email use to take the data
    Subject: Emisión de Work Order C6083525

    ElWalgreens Facilities Maintenance Svc Ctr ha asignado una orden de trabajo de servicio aInternational Maintenance Solutions Corp.
    El número de orden de trabajo referenciado es C6083525
    Debajo están los detalles:
    Fecha de introducción: Ago 17 2016 6:11PM AST
    Prioridad: P10 - Medium (2)
    Respuesta objetivo: Ago 31 2016 4:00PM AST
    Finalización objetivo: Ago 31 2016 4:00PM AST
    Ubicación del servicio:
    940 Carr 123, Utuado, PR, 00641-3201, PR
    País, Estado, Ciudad: PR, PR, Utuado
    Edificio: ******xx Drug Store #185
    Piso: All: 940 Carr 123
    área: ******xx Drug Store #185
    Ubicación dentro de área: (No proporcionada por el solicitante)
    Nombre del solicitante: Don Joe
    Teléfono del solicitante: ***-***-***x
    Nombre de contacto: Don Joe
    Teléfono de contacto: ***-***-***x
    Descripción del problema: Letrero exterior - Letrero manuscrito parcialmente apagado :> todos los letreros de la farmacia estan apagados.
    Last edited by wichie; 08-18-2016 at 07:03 AM. Reason: Add source email

  4. #4
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    If I've understood this task correctly, then expected files can look like the attached CSV and XLSX, which were made by twice running of the fixed code with the same body text.
    But seems the structure and content of other emails can be different, thus some representation of such emails is required for correct parsing.
    Attached Files Attached Files

Posting Permissions

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