A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

File all Emails by Sender in the Inbox and Move to Folder according to Pre-set Rule



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 3rd 07, 02:40 PM posted to microsoft.public.outlook.program_vba
ollie
external usenet poster
 
Posts: 2
Default File all Emails by Sender in the Inbox and Move to Folder according to Pre-set Rule

Hopefully Sue can help me or someone else here.

I need to right a macro in order to make filing my Inbox emails simpler
in outlook 2003.

Simply, I want to right Click an Email that's in my Inbox and then have
ALL of the emails from the sender in my Inbox "MOVED" to a
pre-determined sub folder (from a rule).

So I can and have created rules to move emails from specific Senders to
the folder as they arrive but basically I want to read the emails
first that arrive in my Inbox and then "Move Them" to a pre-specified
folder that I have determined using the Rule Wizard.

So I first create the rule but turn off run rules automatically for the
ones which say emails from Sender X move to Folder Y.

Now I need to create the Right-Click Menu Macro to 'File All Senders
Emails'.

Could someone show me the VBA Code necessary to do this Please?

Logic is this.

With
Current Selected Mail Item
Search All Mail Items with Senders Name in Current Folder
Where Rule Contains Name of Sender Run this Rule for All Mail Items
in Current Folder

Obviously it would be better if Outlook could have Subfolders
associated to Contacts in the Addressbook that way instead of having to
run the rule wizard, for certain filing actions, you could call the
associated Folder Property in VBA or .NET.

Many Thanks

Ollie

Ads
  #2  
Old January 3rd 07, 03:27 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default File all Emails by Sender in the Inbox and Move to Folder according to Pre-set Rule

Using the context menu in an Explorer is a hack in versions earlier than
Outlook 2007 and does not tell you which item was right-clicked. If it's the
ActiveExplorer.Selection(1) item and only 1 item is selected it might work,
otherwise forget it. For code to work with the context menu search for
"context menu" at www.outlookcode.com, but it's not a real good way.

Why not just run the rule manually when you want to? It's a couple of
additional clicks but it will work.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"ollie" wrote in message
oups.com...
Hopefully Sue can help me or someone else here.

I need to right a macro in order to make filing my Inbox emails simpler
in outlook 2003.

Simply, I want to right Click an Email that's in my Inbox and then have
ALL of the emails from the sender in my Inbox "MOVED" to a
pre-determined sub folder (from a rule).

So I can and have created rules to move emails from specific Senders to
the folder as they arrive but basically I want to read the emails
first that arrive in my Inbox and then "Move Them" to a pre-specified
folder that I have determined using the Rule Wizard.

So I first create the rule but turn off run rules automatically for the
ones which say emails from Sender X move to Folder Y.

Now I need to create the Right-Click Menu Macro to 'File All Senders
Emails'.

Could someone show me the VBA Code necessary to do this Please?

Logic is this.

With
Current Selected Mail Item
Search All Mail Items with Senders Name in Current Folder
Where Rule Contains Name of Sender Run this Rule for All Mail Items
in Current Folder

Obviously it would be better if Outlook could have Subfolders
associated to Contacts in the Addressbook that way instead of having to
run the rule wizard, for certain filing actions, you could call the
associated Folder Property in VBA or .NET.

Many Thanks

Ollie


  #3  
Old January 3rd 07, 04:33 PM posted to microsoft.public.outlook.program_vba
ollie
external usenet poster
 
Posts: 2
Default File all Emails by Sender in the Inbox and Move to Folder according to Pre-set Rule

Thanks Ken,

I have used an example and modified it to get the Context Menu to Work.
So I select a Mail Item and then right click and my macro is in the
Menu.

But I cannot make the code then invoke a rule.

Its too many clicks to make an individual rule run in 2003. You can
only run all or nothing, or go through the wizard for each rule until
you can run it independently! Thats my problem.

If I could invoke a rule based on the SenderName of the Mail Item I
would be away

Do you know How I could do this?

Here is My Context Menu Code That Works:-
_________________

'' This is the right click code (Context Menu Command)
''ok

Dim WithEvents m_objMail As Outlook.MailItem
Dim WithEvents m_objExpl As Outlook.Explorer

Private m_blnIsMailFolder As Boolean
'ok
Private Sub Application_Startup()
Set m_objExpl = Application.ActiveExplorer
End Sub
'ok
Private Sub m_objExpl_Close()
If Application.Explorers.Count 0 Then
Set m_objExpl = Application.ActiveExplorer
Else
Set m_objExpl = Nothing
Set m_objMail = Nothing
End If
End Sub

Private Sub m_objExpl_FolderSwitch()
Dim objFolder As Outlook.MAPIFolder

'Set myMailItems =
myNameSpace.GetDefaultFolder(olFolderInbox).Items

Set objFolder = m_objExpl.CurrentFolder
'Set objFolder = Nothing
End Sub

Private Sub m_objExpl_SelectionChange()
Dim objItem As Object
Dim objAction As Outlook.Action
If m_objExpl.Selection.Count 0 Then
Set objItem = m_objExpl.Selection(1)
If objItem.Class = olMail Then
Set m_objMail = objItem
Set objAction = m_objMail.Actions("My Reply")
If objAction Is Nothing Then
Set objAction = m_objMail.Actions.Add
With objAction
.Enabled = True
.Name = "My Reply"
.ShowOn = olMenu
End With
m_objMail.Save
End If
End If
End If
Set objItem = Nothing
Set objAction = Nothing
End Sub



Private Sub m_objMail_CustomAction(ByVal Action As Object, _
ByVal Response As Object, _
Cancel As Boolean)
MsgBox Action.Name, , "m_objMail_CustomAction"


Cancel = True
End Sub

  #4  
Old January 3rd 07, 07:37 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default File all Emails by Sender in the Inbox and Move to Folder according to Pre-set Rule

You cannot call a rule from code unless you are using Outlook 2007 and
access the new Rules collection. You would have to replicate the entire rule
using your macro code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"ollie" wrote in message
ups.com...
Thanks Ken,

I have used an example and modified it to get the Context Menu to Work.
So I select a Mail Item and then right click and my macro is in the
Menu.

But I cannot make the code then invoke a rule.

Its too many clicks to make an individual rule run in 2003. You can
only run all or nothing, or go through the wizard for each rule until
you can run it independently! Thats my problem.

If I could invoke a rule based on the SenderName of the Mail Item I
would be away

Do you know How I could do this?

Here is My Context Menu Code That Works:-
_________________

'' This is the right click code (Context Menu Command)
''ok

Dim WithEvents m_objMail As Outlook.MailItem
Dim WithEvents m_objExpl As Outlook.Explorer

Private m_blnIsMailFolder As Boolean
'ok
Private Sub Application_Startup()
Set m_objExpl = Application.ActiveExplorer
End Sub
'ok
Private Sub m_objExpl_Close()
If Application.Explorers.Count 0 Then
Set m_objExpl = Application.ActiveExplorer
Else
Set m_objExpl = Nothing
Set m_objMail = Nothing
End If
End Sub

Private Sub m_objExpl_FolderSwitch()
Dim objFolder As Outlook.MAPIFolder

'Set myMailItems =
myNameSpace.GetDefaultFolder(olFolderInbox).Items

Set objFolder = m_objExpl.CurrentFolder
'Set objFolder = Nothing
End Sub

Private Sub m_objExpl_SelectionChange()
Dim objItem As Object
Dim objAction As Outlook.Action
If m_objExpl.Selection.Count 0 Then
Set objItem = m_objExpl.Selection(1)
If objItem.Class = olMail Then
Set m_objMail = objItem
Set objAction = m_objMail.Actions("My Reply")
If objAction Is Nothing Then
Set objAction = m_objMail.Actions.Add
With objAction
.Enabled = True
.Name = "My Reply"
.ShowOn = olMenu
End With
m_objMail.Save
End If
End If
End If
Set objItem = Nothing
Set objAction = Nothing
End Sub



Private Sub m_objMail_CustomAction(ByVal Action As Object, _
ByVal Response As Object, _
Cancel As Boolean)
MsgBox Action.Name, , "m_objMail_CustomAction"


Cancel = True
End Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
move to folder rule sends to wrong folder Holden Outlook - General Queries 0 December 10th 06 07:18 AM
How to create a rule to move emails based on a particular domain Net Outlook - General Queries 3 November 22nd 06 02:35 PM
O2k3: single keystroke to move a message(s) to a pre-determined folder(s). Michael March Outlook - General Queries 1 August 6th 06 07:44 PM
How can set up a rule to I move emails from contacts in a given category... into a particular email folder? ship Outlook - General Queries 3 April 27th 06 11:28 PM
Move emails to a folder rule (Time based) George Lake Outlook - General Queries 1 April 27th 06 03:09 PM


All times are GMT +1. The time now is 05:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.