Results 1 to 9 of 9

Thread: VBA Access to connect to Outlook

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    VBA Access to connect to Outlook

    Hello,

    Can anyone send me code to connect to oulook and get information from oulook from Visual basic or VBA.

    Thanks,

    Prasad

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VBA Access to connect to Outlook

    What information are you looking for?

    Also, the methods of gathering this is sightly different between VB and VBA. Which platform will you be using?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: VBA Access to connect to Outlook

    I will be using VBA and want to get first name,last name,middle and alias name.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VBA Access to connect to Outlook

    Quote Originally Posted by kprasadreddy
    I will be using VBA and want to get first name,last name,middle and alias name.
    From the properties page of the Global Address Book?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: VBA Access to connect to Outlook

    from the work outlook in the company

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: VBA Access to connect to Outlook

    I want to be able to get all the firstnames, lastnames and aliases in the outlook exchange server in our company.

    Also I am trying to add a contact to my oulook from code...

    Private Sub CmdAddContact_Click()
    Dim objOutlook As New Outlook.Application
    Dim objContact As ContactItem
    Set objContact = objOutlook.CreateItem(olContactItem)
    With objContact
    .First = "xyz"
    .Last = "test"
    .Alias = "E123456"
    .Save 'Save the new contact
    End With
    Set objContact = Nothing
    Set objOutlook = Nothing

    End Sub

    and get a message at .First =""xyz"

    Runtime error '438'
    Object doesnt support this propery or method

    Any help is greatly appreciated.

    Thanks,

    Prasad
    Last edited by kprasadreddy; Oct 13th, 2005 at 03:24 PM.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VBA Access to connect to Outlook

    VBA question moved to Office Development.

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: VBA Access to connect to Outlook

    I used to go into the GroupWise AddressBook, and select EXPORT ALL, and download it to a PC, and then zip it to a floppy disk. Wasn't pretty, but it worked.

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

    Re: VBA Access to connect to Outlook

    Well the poster does not want to do it manually as stated in his post he wants to do it programmatically.

    If you want to get the local Contacts and not Global ones then your code only needs a little tweeking.

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim objOutlook As New Outlook.Application
    3.     Dim objContact As Outlook.ContactItem
    4.    
    5.     Set objContact = objOutlook.CreateItem(olContactItem)
    6.     With objContact
    7.         .FirstName = "xyz"
    8.         .LastName = "test"
    9.         '.Alias = "E123456" 'Not supported using the OOM
    10.         .Save 'Save the new contact
    11.     End With
    12.     Set objContact = Nothing
    13.     objOutlook.Quit
    14.     Set objOutlook = Nothing
    15. End Sub
    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