Outlook 2007 Macro Open Contact Folder

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
The following code is what you gave me that when I select a contact, it moves to the specific folder or sub folder or sub sub folder....this is an example for a folder to a bank name....so what can I add at the end that it still moves the contact to the folder put in the code, but it also opens up that folder? Since I have many many folders, this would be helpful.

Sub MoveSelectedContactsToContacts_Marketing_Marketing_Banks_Community_Bank_of_Texas()
Dim objFolder As outlook.MAPIFolder, objInbox As outlook.MAPIFolder
Dim objNS As outlook.NameSpace, objItem As outlook.contactItem
Set objNS = Application.GetNamespace("MAPI")
Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
On Error Resume Next
Set objFolder = objContacts.Folders("Marketing -").Folders("Marketing - Banks").Folders("Marketing - Banks - Community Bank of Texas")
'Assume this is a contact folder
If objFolder Is Nothing Then
MsgBox "This folder doesn’t exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a contact is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olContactItem Then
If objItem.Class = olContact Then
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
 
I put it after: objItem.Move objFolder and it worked...thanks very very much!
 
Hope you get this question. Can we change the code so it searches the emails sent based on the email in that note field of the email message I receive....that way it shows the emails I sent to non- received contact....????

so you want to look for an address in a message body? sure, you can do that. it shouldn't take much to take the parts you need from the other macro and put them together with this one. I'm not sure i'll have time to look at it - i have a pile of work and a holiday weekend coming up.

You misunderstand....It uses the email from the message body and searches that email address in the Outlook Sent E-mail folder. that's want I want to do.

Here is the code I found that searches the Sent emails based on the contact that sent an email....so is there something in this to add and/or replace re the code that finds the contact based on the email address in the message body?

Sub SearchByAddressToContact()

Dim myOlApp As New outlook.Application
Dim ns As outlook.NameSpace
Dim strFilter As String
Dim oMail As outlook.mailItem

Set ns = myOlApp.GetNamespace("MAPI")

Set oMail = Application.ActiveExplorer.Selection.Item(1)
strFilter = oMail.SenderEmailAddress

Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox)
txtSearch = "to:(" & strFilter & ")"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders

Set myOlApp = Nothing

End Sub

Above I pasted wrong so here it is:

Sub SearchByAddressToContact()

Dim myOlApp As New outlook.Application
Dim ns As outlook.NameSpace
Dim strFilter As String
Dim oMail As outlook.mailItem

Set ns = myOlApp.GetNamespace("MAPI")

Set oMail = Application.ActiveExplorer.Selection.Item(1)
strFilter = oMail.SenderEmailAddress

Set myOlApp.ActiveExplorer.CurrentFolder = ns.GetDefaultFolder(olFolderInbox)
txtSearch = "to:(" & strFilter & ")"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders

Set myOlApp = Nothing

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
L Outlook 2007 - Macro Re Search Using Outlook 16
L Outlook 2007 Macro to Contact From a Field Using Outlook 3
L Outlook 2007 Macro Save Contact Using Outlook 10
L Outlook 2007 Macro Reply to E-mail Using Outlook 16
L Outlook 2007 Macro Search Contacts Using Outlook 9
L Outlook 2007 Macro to LinkedIn Using Outlook 3
L Macro to Open a Specific Word Document - Outlook 2007 Using Outlook 17
L Outlook 2007 Macro For Views Using Outlook 10
L Outlook 2007 Macro to Run a Script From a Contact Form Using Outlook 41
L Outlook 2007 Macro to Add Text to a Contact Field Using Outlook 10
F Help with Outlook 2007 Macro Please! Using Outlook 4
D outlook 2003/2007 macro query Using Outlook 2
L Outlook 2007 Macro to Email Field Using Outlook 31
O Macro for creating hyperlinks in Outlook 2007 Using Outlook 3
S Outlook 2007 Macro for replying to an e-mail. Outlook VBA and Custom Forms 1
J Can't run macro Outlook 2007 that was created in Word 2007 Outlook VBA and Custom Forms 1
I Creating an Outlook 2007 macro that attaches a signature to new me Outlook VBA and Custom Forms 1
L Help for writing an Outlook 2007 macro Outlook VBA and Custom Forms 7
D Insert Text via Macro in Outlook 2007 Outlook VBA and Custom Forms 2
G Outlook 2007 Macro: Paste - Paste Special - Unformatted Text Outlook VBA and Custom Forms 9
C After Office 2007 SP2 install - Outlook 2007 macro no longer worki Outlook VBA and Custom Forms 11
R Anyone have a sample macro for Outlook 2007 (setting the zoom)? Outlook VBA and Custom Forms 1
S Outlook 2007: automating form with macro Outlook VBA and Custom Forms 2
S How to create a macro to insert a signature in Outlook 2007 Outlook VBA and Custom Forms 1
D Outlook 2007 Recovering E-Mails Using Outlook 0
W Transfer Outlook 2016 autocomplete file to Outlook 2007 Using Outlook 1
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
S Outlook 2007 - Automatic purge fail Using Outlook 0
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Verwendung von Outlook 2007 Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
S Reboot of frozen windows7 results in changed outlook 2007 settings Using Outlook 1
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
M Configure outlook 2007 to accept digital signatures Using Outlook 2
D Outlook 2007 crashes when opening an email Using Outlook 2
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3

Similar threads

Back
Top