+ Reply to Thread
Results 1 to 7 of 7

Thread: Export outlook body data to excel

  1. #1
    Registered User
    Join Date
    12-31-2003
    Posts
    3

    Export outlook body data to excel

    I have been looking for a macro which will extract data from the currently highlighted email in outlook and append it to a specified worksheet in an Excel workbook.

    If the incoming body contains

    Name: Joe Bloggs
    Age:32

    then the macro should send the data to the next empty row in the sheet.

    Does anyone know how I can do this or provide a link with some examples to work from.

    tia

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    768

    Re: Export outlook body data to excel

    is this for a personal solution for or has it got to work within a corporate network and exchange server?

    How will the workbook be identified?
    Is it always the same data?
    Is the incoming email a fixed format?

    It all affects how to tackle the solution.


    Hope this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    12-31-2003
    Posts
    3

    Re: Export outlook body data to excel

    The solution is a personal one on a stand alone PC.
    The data is always in the same format and the only changes are in the values of the data.

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    768

    Re: Export outlook body data to excel

    OK,
    but I can only be half helpful as I don't have outlook installed on this PC.

    Basically there are two options: 1. write an excel macro to get the data from Outlook and 2. write an Outlook macro to push the data to Excel.

    in your case you will be better off with an Outlook Macro. You will need to add Excel as a reference in tools. and makesure you decalre Range object with the full class name or you will have problems.

    I think when you install Outlook it doesn't install all the programming part unless you specifically request it.



    If you are still stuck in a week ask me again I might be back with another PC.


    Hope this was useful or entertaining.

  5. #5
    Registered User
    Join Date
    03-31-2010
    Location
    Chicag, United States
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Export outlook body data to excel

    I have a similar issue but have never created a macro for Outlook or Excel.

    I have 2 forms on the web that are sent to an email box/folder. When I export them chosing only the body as a Windows Tab Delimited text file there is a lot of other information that goes into the cells not just the form field information. Here are the two forms.

    Form 1
    First Name:
    Last Name:
    Your e-Mail Address:
    Program Confirmation Number:


    Form 2
    First Name:
    Last Name:
    Your e-Mail Address:
    Participation Verification Code:

    It would be great to be able to append the information into Excel but I would settle for just getting the field information cleanly into columns. If anyone has a macro that I can use as a starting point it would be very helpful.

    Thanks,

    Denny

  6. #6
    Registered User
    Join Date
    12-31-2003
    Posts
    3

    Re: Export outlook body data to excel

    I have trawled the net looking for anything that would let me move just one item of data.
    It would give me a start and I would have something to work with.

    I can't believe that so few people would find this useful that no-one would create such a macro.

  7. #7
    Registered User
    Join Date
    11-09-2008
    Location
    germany
    Posts
    74

    Re: Export outlook body data to excel

    If you do this from Outlook you will not run into security issues. If you do this from Excel or some other program Office will throw up warning messages every time you try to read the body of the email.

    This would work from Outlook - but you could change it to work from excel as well

    'Sub sendtoaccess()
    
    'Dim out_app As Outlook.Application
    'Dim out_Exp As Outlook.Explorer
    'Dim out_Sel As Outlook.Selection
    'Dim out_mail As Outlook.MailItem
    
    Set out_app = Application
    
    'get the active explorer
    Set out_Exp = out_app.ActiveExplorer
    '
    If out_Exp.CurrentFolder.WebViewOn = False Then
            Set out_Sel = out_Exp.Selection
        Else
           MsgBox "wrong item type"
            Set out_Exp = Nothing
            Exit Sub
       End If
    
    ''first make sure they have only choosen one item if not exit sub
    If out_Sel.Count > 1 Then
        MsgBox "more than one item"
        Exit Sub
    Else
        If out_Sel.Count = 0 Then
        MsgBox "nothing choosen"
        Exit Sub
        End If
    End If
    '
    ''check that it is in fact an email that has been choosen
    If Not out_Sel.Item(1).Class = olMail Then
        MsgBox "not an email"
        Exit Sub
    End If
    '
    '
    'next try to get the email item - if there is an error 13 then it is encrypted - you may not need this one
    On Error Resume Next
    
    Set out_mail = out_Sel.Item(1)
    
    If Err.Number = 13 Then
        Err.Clear
        MsgBox "email encrypted"
        Exit Sub
    End If
    '
    '
    ''***********************************
    ''now you have your email item so you can get any property you want
    ''I will just show an example
    ''
    '
    Dim str_emailBody As String
    Dim str_emailSubject As String
    '
    str_emailBody = out_mail.Body
    str_emailSubject = out_mail.Subject
    'add your others here.  Then you need to decide how to get this to excel.  
    '
    you could even add this as a button in outlook. Then just select a message and press the button.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0