Results 1 to 4 of 4

Thread: Outlook instance problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Outlook instance problem

    I am trying to kill outlook instance...

    [code]
    'Create a reference to namepsace
    Dim nmsName As outlook.NameSpace
    Set nmsName = objout.GetNamespace("MAPI")


    'Create an instance of the sentmail folder
    Dim fldfolder As outlook.MAPIFolder
    Set fldfolder = nmsName.GetDefaultFolder(outlook.OlDefaultFolders.olFolderSentMail)
    [\code]

    Code:
    Set nmsName = Nothing
    Set fldfolder = Nothing
    
    objout.Quit
    Set objout = Nothing
    Instance is not going...

    Or is there any way i can get that outlook application is open?

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

    Re: Outlook instance problem

    VB Code:
    1. objout.Logoff
    2. objout.Quit
    3. Set objout = Nothing
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Outlook instance problem

    tHERE IS NO PROPERTY AS :

    OUTLOOKOBJECT.logoff

    [code]
    Dim O As New Outlook.Application
    Dim C As mapiFolder
    Dim M As MAPI.Session
    Dim CI As ContactItem
    Private Sub Command1_Click()
    Set C = O.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    For Each CI In C.Items

    MsgBox CI.Subject
    Set CI = Nothing
    Next


    On Error Resume Next
    Set M = CreateObject("mAPI.Session")
    M.Logon

    MsgBox O.Name
    M.Logoff
    Set M = Nothing
    O.Quit
    Set O = Nothing

    End Sub
    [\code]

    For this small code snippet outlook instance dosn't go...

    If i remove for loop its going..
    Can anyone tell me why?

    Thanks...

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

    Re: Outlook instance problem

    I see what your doing here. From your original posted code you didnt have all your object variables defined. Now with your new post it looks like your mixing the API control with the Outlook Object Model. You only need to use one or the other
    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim oApp As Outlook.Application
    4.     Dim oNS As Outlook.Namespace
    5.     Dim oFolder As Outlook.MAPIFolder
    6.     Dim oContact As Outlook.ContactItem
    7.  
    8.     Set oApp = New OutlookApplication
    9.     Set oNS = oApp.GetNamespace("MAPI")
    10.     Set oFolder = oNS.GetDefaultFolder(olFolderContacts)
    11.    
    12.     For Each oContact In oFolder.Items
    13.         MsgBox oContact.Subject
    14.         Set oContact = Nothing
    15.     Next
    16.  
    17.     Set oFolder = Nothing
    18.     Set oNS = Nothing
    19.     oApp.Session.Logoff
    20.     oApp.Quit
    21.     Set oApp = Nothing
    22.  
    23. 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