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

Code to move task from inbox to a task folder



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old April 18th 08, 04:47 PM posted to microsoft.public.outlook.program_vba
LDMueller
external usenet poster
 
Posts: 53
Default Code to move task from inbox to a task folder

First of all Sue, thank you for your assistance. You have helped me many
times in the past.

Since neither MailItem or MeetingItem will work for an incoming task (I
tested it), I assume using a "run a script" rule is not an option.

So at this point, I'm not even sure of a direction. All I really want to
accomplish is when I receive new task with "Please consider" in the subject,
I want to accept these tasks and move them to a task folder named "AAA".

If there's any other direction someone can suggest or code someone could
provide for this I would greatly appreciate it.

Thanks again!

LDMueller

"Sue Mosher [MVP-Outlook]" wrote:

A procedure for use with a "run a script" rule action needs a MailItem or MeetingItem as its parameter. That item is processed by the code. For example:

Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim rply as Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
Set rply = msg.Reply
rply.Body = "What you want the reply to say."
rply.To = ; "
rply.Send

Set msg = Nothing
Set rply = Nothing
Set olNS = Nothing
End Sub

You might also want to take a look at the sample at
http://www.outlookcode.com/codedetail.aspx?id=959, which takes a different approach to what you're trying to do.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"LDMueller" wrote in message ...
I'm trying to automate my Outlook mailbox so when a task appears in my inbox
with the subject

starting with "Please consider" that it is moved to my task folder named
"AAA".

My direction is that I've created an Outlook Rule whose criteria is having
"Please consider" in

the subject and then it runs a script.

The script needs to move the task for me, but this is where I'm having
problems since I'm

limited to what I know.

Below is my snippet which only works if I go into the task folder, highlight
all the entries

and run the code.

Sub MoveTaskToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.TaskItem

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("AAA")

For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olTaskItem Then
objItem.Move objFolder
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing

End Sub


Can anyone help me with this.


 




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
2 simple macros - create task from email and move email to folder [email protected] Outlook and VBA 5 February 4th 07 09:57 AM
How do I move a Daily Task to the Master Task List? Carol Outlook - General Queries 0 November 17th 06 05:57 PM
Can not open "task request" "task accepted" in Inbox LaParker Outlook - General Queries 2 August 9th 06 10:09 PM
Task 'Hotmail: Folder:Inbox Synchronizing headers.' reported error (0x80004005) baduser Outlook - General Queries 4 July 21st 06 09:46 AM
VBA Code to check Task Status [email protected] Outlook and VBA 2 February 3rd 06 06:16 PM


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


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