Results 1 to 2 of 2

Outlook to Excel - list of inbox

Threaded View

siray13 Outlook to Excel - list of... 09-08-2012, 11:50 AM
jayinthe813 Re: Outlook to Excel - list... 09-09-2012, 12:27 AM
  1. #1
    Registered User
    Join Date
    06-16-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    24

    Outlook to Excel - list of inbox

    i am trying to figure out how to have an excel file updated every time an email arrives, I would like to have

    Sender
    Sent time
    Subject
    Body

    in four separate columns. I know this may not be the appropriate forum but I can not seem to figure out how to do this and you guys seem to have the answers to everything. I am using 2010. Any suggestions would be helpful. Thanks!

    I found this code on mrexcel, but I haevnt gotten it to work yet, run time error 1004, it opens the excel sheet- the first time it dumped information in one cell but I have not been able to get it to process anything since then.

    Private Sub Application_NewMail()
    
        Dim objNS As NameSpace
        Dim objFolder As MAPIFolder
        Dim myItem As MailItem
    
        Dim myXLApp As Excel.Application
        Dim myXLWB As Excel.Workbook
        Dim StrBody As String
        Dim TotalRows As Long, i As Long
        
        Set objNS = GetNamespace("MAPI")
        Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
        Set myItem = objFolder.Items(1)
        
        Set myXLApp = New Excel.Application
        myXLApp.Visible = True
        Set myXLWB = myXLApp.Workbooks.Add
        
        TotalRows = Sheets(1).Range("A65536").End(xlUp).Row
        i = TotalRows + 1
        
        With myXLWB.Worksheets(1)
            .Cells(i, 1) = Format(myItem.SentOn, "mm/dd/yyyy")
            .Cells(i, 2) = myItem.SenderName
            .Cells(i, 3) = myItem.To
            .Cells(i, 4) = myItem.Body
        End With
        
    End Sub
    Last edited by siray13; 09-08-2012 at 05:01 PM.

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.6.0 RC 1