Solved

MS Outlook 2010 and Lync

Posted on 2013-01-25
4
1,422 Views
Last Modified: 2013-01-30
I have MS Outlook 2010 and Lync which adds the folder “Conversation History”.  I have some vba that moves my deleted folder items to an external pst file each time I shut down Outlook.  I want to do the same thing for the Conversation History file but I cannot figure out what to use in the ‘GetDefaultFolder’ command.  Here is what I have tried for code and it fails to compile with “variable not defined” on the line “Set objTrash = Outlook.Application.Session.GetDefaultFolder(olFolderConversationHistory).Items”

Sub MoveConversationHistory()
     'Move messages from Exchange mailbox folder "Conversation History" to pst
     'Dim and Set
    Dim objFolder As Outlook.MAPIFolder
    Set objFolder = Outlook.Application.GetNamespace("MAPI").Folders("2013_ConversationHistory_Folder")
    Dim objTrash As Outlook.Items
    Set objTrash = Outlook.Application.Session.GetDefaultFolder(olFolderConversationHistory).Items
    Dim objDrafts As Outlook.Items

    Dim objItem As Object
    Dim objDraftItem As Object
    Dim varMsgID As String
   
    Dim varLoopCounter, x As Integer
   
    varLoopCounter = objTrash.Count
   
    For x = 1 To varLoopCounter
   
      Set objTrash = Outlook.Application.Session.GetDefaultFolder(olFolderConversationHistory).Items
   
      For Each objItem In objTrash

      '  Debug.Print "Moving Item: " & objItem.Subject & " - " & objItem.Class

        objItem.Move objFolder

        Exit For
      Next
   
    Next x
   
    Set objItem = Nothing
    Set objDraftItem = Nothing
    Set objFolder = Nothing
    Set objDrafts = Nothing
    Set objTrash = Nothing
   
End Sub

Thanks in advance,

Jim
0
Comment
Question by:phonepagerfax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
jrlingam earned 500 total points
ID: 38822575
Hi

Its been so long since I wrote macros. I have just tried to get to the parent folder of Inbox which is the mailbox itself and then retrieve all the subfolders by their name.

Dim objNS As Outlook.Namespace
Dim objFolder As Outlook.MAPIFolder

Set objNS = Outlook.Application.GetNamespace("MAPI")

Dim varStr As String

Set objFolder = objNS.GetDefaultFolder(olFolderInbox)

varStr = objFolder.Parent

Set objMbx = objNS.Folders(varStr)

Set objFolder = objMbx.Folders("Conversations History")

Hope this helps.

Thanks
jrlingam.
0
 

Author Comment

by:phonepagerfax
ID: 38830934
jrlingam,

I'm hopeful this will work.  When I compile the code I get objMbx variable not defined.  What should I dim it as?  I tried Outlook.Items but then I got objNs.Folders(varStr) type mismatch when I ran the code.  varStr did equal "myemail@mycompany.com".

Thanks for the help,

Jim
0
 

Author Comment

by:phonepagerfax
ID: 38831243
jrlingam,

Thanks for the help, your comments got me thinking and I was able to get it to work.  Here is the code.  I hard coded the parent stuff but using your code I could make it dynamic but, in the end I don't care about this (yet) because I'm the only one using it.

Sub MoveConversationHistory()
'This moves all items from the Conversation History folder into the specific archive file

    'Move messages from Exchange mailbox folder "Conversation History" to pst
   
    Dim objDestinationFolder As Outlook.MAPIFolder
    Dim objSourceFolder As Outlook.MAPIFolder
    Dim objSourceFolderItems As Outlook.Items
    Dim objItem As Object
    Dim varMsgID As String
    Dim x As Integer
   
    'select the existing pst file
    Set objDestinationFolder = Outlook.Application.GetNamespace("MAPI").Folders("2013_ConversationHistory_Folder")
   
    'i think this gets all of the folders for the email address'
    Set objSourceFolder = Outlook.Application.GetNamespace("MAPI").Folders("me@mycompany.com")
   
    'this selects just the conversation history folder
    Set objSourceFolder = objSourceFolder.Folders("Conversation History")
   
    'this select all of the items in the folder
    Set objSourceFolderItems = objSourceFolder.Items
   
    'set the loop counter to the number of items in the folder
'    varLoopCounter = objSourceFolderItems.Count

      For Each objItem In objSourceFolderItems

        'Debug.Print "Moving Item: " & objItem.Subject & " - " & objItem.Class

        objItem.Move objDestinationFolder

      Next

    Set objItem = Nothing
    Set objDestinationFolder = Nothing
    Set objSourceFolder = Nothing
    Set objSourceFolderItems = Nothing

End Sub
0
 
LVL 3

Expert Comment

by:jrlingam
ID: 38838011
Thanks for the update. Glad that I was able to assist you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question