Results 1 to 8 of 8

Transfer Outlook Mail data to Excel

Threaded View

  1. #1
    Registered User
    Join Date
    04-23-2020
    Location
    Canada
    MS-Off Ver
    MS Office 365 ProPlus
    Posts
    32

    Transfer Outlook Mail data to Excel

    Hi, I am trying to export the MS Outlook email data ( Sender name, Subject, Mail body and Date and Time stamp From a Shared Mailbox to excel and need URGENT help in fixing the VBA code for the same.

    I had tried using below code, but this pulls the data from only your current inbox ( and not the shared one) . EG : If my shared mail box name / path is "eTransfer" -> "Inbox", how do i incorporate this in below code?

    Any help will be appreciated.


    VBA Code:
    ____________________

    Sub GetFromOutlook()
    
    Dim OutlookApp As Outlook.Application
    Dim OutlookNamespace As Namespace
    Dim Folder As MAPIFolder
    Dim OutlookMail As Variant
    Dim i As Integer
    
    Set OutlookApp = New Outlook.Application
    Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
    Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Contest")
    
    i = 1
    
    For Each OutlookMail In Folder.Items
        If OutlookMail.ReceivedTime >= Range("From_date").Value Then
            Range("eMail_subject").Offset(i, 0).Value = OutlookMail.Subject
            Range("eMail_date").Offset(i, 0).Value = OutlookMail.ReceivedTime
            Range("eMail_sender").Offset(i, 0).Value = OutlookMail.SenderName
            Range("eMail_text").Offset(i, 0).Value = OutlookMail.Body
            
            i = i + 1
        End If
    Next OutlookMail
    
    Set Folder = Nothing
    Set OutlookNamespace = Nothing
    Set OutlookApp = Nothing
    
    End Sub
    Last edited by Pepe Le Mokko; 04-24-2020 at 02:18 AM. Reason: Code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compose a mail (outlook) from Excel Data
    By Raj.xls in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-25-2019, 04:10 AM
  2. Automating transfer of Outlook emails data to Excel
    By yawwwn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2015, 02:01 AM
  3. code to compose outlook mail with the excel data
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2014, 04:53 AM
  4. How to extract data from Outlook Mail to Excel (VBA)
    By rafeemd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2011, 01:16 AM
  5. Transfer data from Excel to Outlook Calendar
    By Hatye in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 01-10-2011, 05:19 AM
  6. Replies: 3
    Last Post: 07-07-2006, 04:10 PM
  7. [SOLVED] HOW DO I TRANSFER DATA FROM EXCEL SPREADSHEET TO OUTLOOK
    By msmagoo in forum Excel General
    Replies: 1
    Last Post: 01-16-2006, 01:40 PM

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