Results 1 to 3 of 3

Thread: get information from outlook to excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    1

    get information from outlook to excel

    How can I:
    flag an e-mail using a rule in outlook
    from excel look for those flags
    when found copy the text of the e-mail into excel and process it
    then change the flag to completed
    look for the next flag
    if none quit outlook

    I've tried several samples of code and so far I can't seem to open outlook from excel.

    Thanks

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: get information from outlook to excel

    the reading of the BODY of the email will cause a security popup that makes the user
    allow it to interact with outlook....(im using outlook 2003)

    just put this in a module in excel and add a reference to the outlook x.0 object library
    VB Code:
    1. Private Sub GetMail()
    2.     Dim OTL As New Outlook.Application
    3.     Dim MAPI As Outlook.Namespace
    4.     Dim INBOX As Outlook.MAPIFolder
    5.     Dim MAIL As Outlook.MailItem
    6.     Set MAPI = OTL.GetNamespace("MAPI")
    7.     Set INBOX = MAPI.GetDefaultFolder(olFolderInbox)
    8.     For Each MAIL In INBOX.Items
    9.         If MAIL.FlagIcon = olRedFlagIcon Then
    10.             Debug.Print MAIL.Subject 'this will work without causing security popup
    11.             Debug.Print MAIL.Body 'this WILL cause the security popup
    12.         End If
    13.     Next
    14.     Set MAIL = Nothing
    15.     Set INBOX = Nothing
    16.     Set Map = Nothing
    17.     Set OTL = Nothing
    18. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: get information from outlook to excel

    You also need to add a reference to MS Outlook xx.0 Object Library from Excels Project > References menu item.

    I also have many many Outlook code examples on the forums.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width