![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I am trying to create a process that will automatically create a task
from an incoming email message. My current approach uses a rule to identify an email I have sent to myself, then runs a VBA Script. Problem is I can't get the script to work, and am not skilled enough to figure out why it is not working. If anyone can tell me what I need to change to get it to work that would be great. Also, if someone has a better approach, I'm open to suggestions. Thanks. Sub CopyIncomingEmailtoWaitingForTask(Item As Outlook.MailItem) 'Use this to tie to a Rule that automatically creates task for Waiting Items on Incoming items I copied myself on Dim olmailitem As Outlook.MailItem Dim ti As TaskItem Dim fldCurrent As MAPIFolder Set fldCurrent = Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B21100805FA730C90100F8C990 7DFE3BD611B20400805FA730C90000064BAD4F0000") Set ti = fldCurrent.Items.Add ti.Body = olmailitem.Body & vbCrLf & vbCrLf ti.Attachments.Add MailItem ti.Subject = olmailitem.SenderName & olmailitem.Subject & olmailitem.SentOn ti.Categories = "@Waiting For" olmailitem.Move Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B21100805FA730C90100F7CBF6 1AE174914C9E364B416FA0A91600000154A1DB0000") ti.Save End Sub |
Ads |
#2
|
|||
|
|||
![]()
Does the code get called?
What version of Outlook? Have you stepped the code to see what's not working? Are you sure those folder EntryID's are valid? You realize that olmailitem is null? Also, Move is a function. If you are using NameSpace twice you should instantiate a NameSpace object. If you really want to move ti then save it before moving it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... I am trying to create a process that will automatically create a task from an incoming email message. My current approach uses a rule to identify an email I have sent to myself, then runs a VBA Script. Problem is I can't get the script to work, and am not skilled enough to figure out why it is not working. If anyone can tell me what I need to change to get it to work that would be great. Also, if someone has a better approach, I'm open to suggestions. Thanks. Sub CopyIncomingEmailtoWaitingForTask(Item As Outlook.MailItem) 'Use this to tie to a Rule that automatically creates task for Waiting Items on Incoming items I copied myself on Dim olmailitem As Outlook.MailItem Dim ti As TaskItem Dim fldCurrent As MAPIFolder Set fldCurrent = Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B21100805FA730C90100F8C990 7DFE3BD611B20400805FA730C90000064BAD4F0000") Set ti = fldCurrent.Items.Add ti.Body = olmailitem.Body & vbCrLf & vbCrLf ti.Attachments.Add MailItem ti.Subject = olmailitem.SenderName & olmailitem.Subject & olmailitem.SentOn ti.Categories = "@Waiting For" olmailitem.Move Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B21100805FA730C90100F7CBF6 1AE174914C9E364B416FA0A91600000154A1DB0000") ti.Save End Sub |
#3
|
|||
|
|||
![]()
It is Outlook 2003. No I have not stepped through the code. I don't
know how to do that. I'm pretty sure the Entry ID's are valid. I used a code someone else gave me that retrieves the entry id for the folder. No, I don't realize that olmailitem is null. I don't know what you mean when you say "Move is a function". I don't understand what you are saying about NameSpace. I am a novice. I know how to copy code that people give me, and maybe manipulate some basic things. Other than that, I don't understand VBA. So if you could fix the code for me that would help. Thanks. On Jan 9, 6:13*pm, "Ken Slovak - [MVP - Outlook]" wrote: Does the code get called? What version of Outlook? Have you stepped the code to see what's not working? Are you sure those folder EntryID's are valid? You realize that olmailitem is null? Also, Move is a function. If you are using NameSpace twice you should instantiate a NameSpace object.. If you really want to move ti then save it before moving it. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... I am trying to create a process that will automatically create a task from an incoming email message. *My current approach uses a rule to identify an email I have sent to myself, then runs a VBA Script. Problem is I can't get the script to work, and am not skilled enough to figure out why it is not working. *If anyone can tell me what I need to change to get it to work that would be great. *Also, if someone has a better approach, I'm open to suggestions. *Thanks. Sub CopyIncomingEmailtoWaitingForTask(Item As Outlook.MailItem) 'Use this to tie to a Rule that automatically creates task for Waiting Items on Incoming items I copied myself on * *Dim olmailitem As Outlook.MailItem * *Dim ti As TaskItem * *Dim fldCurrent As MAPIFolder * *Set fldCurrent = Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B*21100805FA730C90100F8C99 07DFE3BD611B20400805FA730C90000064BAD4F0000") * *Set ti = fldCurrent.Items.Add * *ti.Body = olmailitem.Body & vbCrLf & vbCrLf * *ti.Attachments.Add MailItem * *ti.Subject = olmailitem.SenderName & olmailitem.Subject & olmailitem.SentOn * *ti.Categories = "@Waiting For" * *olmailitem.Move Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B*21100805FA730C90100F7CBF 61AE174914C9E364B416FA0A91600000154A1DB0000") ti.Save End Sub- Hide quoted text - - Show quoted text - |
#4
|
|||
|
|||
![]()
How about this approach? It checks your inbox for new emails, and then
creates a corresponding task. Note that it will do this for every single email added to your Inbox. Also, Outlook has to be running for it to work. In the 'ThisOutlookSession' module, paste in this code: (assuming you don't already have Startup Event code) Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") Set Items = objNS.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemAdd(ByVal Item As Object) Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") If TypeOf Item is Outlook.MailItem Then Dim objTask As Outlook.TaskItem Set objTask = CreateItem(olTaskItem) With objTask .Subject = Item.Subject .StartDate = Now + 2 .Status = olTaskInProgress .Importance = Item.Importance .Body = Item.Body .Save End With Set objTask = Nothing Set objNS = Nothing End Sub HTH, JP On Jan 9, 5:07*pm, Murphybp2 wrote: I am trying to create a process that will automatically create a task from an incoming email message. *My current approach uses a rule to identify an email I have sent to myself, then runs a VBA Script. Problem is I can't get the script to work, and am not skilled enough to figure out why it is not working. *If anyone can tell me what I need to change to get it to work that would be great. *Also, if someone has a better approach, I'm open to suggestions. *Thanks. Sub CopyIncomingEmailtoWaitingForTask(Item As Outlook.MailItem) 'Use this to tie to a Rule that automatically creates task for Waiting Items on Incoming items I copied myself on * * Dim olmailitem As Outlook.MailItem * * Dim ti As TaskItem * * Dim fldCurrent As MAPIFolder * * Set fldCurrent = Application.GetNamespace("MAPI").GetFolderFromID(" 00000000FB410B46958BD711B*21100805FA730C90100F8C99 07DFE3BD611B20400805FA730C90000064BAD4F0000") |
#5
|
|||
|
|||
![]()
I can't just "fix" your code since I don't know what it's supposed to be
doing and I have no idea of whether or not the id's you're using would work. I'd suggest getting a good beginners book on Outlook programming, like Sue Mosher's book, and learning what you're doing from that. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... It is Outlook 2003. No I have not stepped through the code. I don't know how to do that. I'm pretty sure the Entry ID's are valid. I used a code someone else gave me that retrieves the entry id for the folder. No, I don't realize that olmailitem is null. I don't know what you mean when you say "Move is a function". I don't understand what you are saying about NameSpace. I am a novice. I know how to copy code that people give me, and maybe manipulate some basic things. Other than that, I don't understand VBA. So if you could fix the code for me that would help. Thanks. |
#6
|
|||
|
|||
![]()
Well, unfortunately, I don't have the time to study up on the
subject. I thought I had explained what I was trying to do, but let me try again. I want to be able to create a task in Outlook 2003 for certain email messages based a certain criteria. The scenario is this. I am going to send a message to someone and want to make sure to follow up on what I ask them to do. So when I send the message, I also send a blind copy to myself, by entering my name in the BCC field. When this message is delivered to my inbox, I would like for the system to automatically recognize that this is an email with my name in the BCC field. Then to use that message to create a task. For the task, I want the following things to happen. 1) Copy the original message into the body of the Task 2) Copy the name from the "To" field of the message into the subject line of the Task 3) Then to copy the subject of the email message and put it in the subject of the Task, after the name from # 2. 4) I want to populate the category field with the text "@Waiting". 5) I want to move the original email to a reference folder that I have. ( which is where the entry ID comes from. I know this entry ID is correct because I have other macros that move messages to this folder that work). I hope this gives a better idea of what I'm trying to do. On Jan 10, 1:23 pm, "Ken Slovak - [MVP - Outlook]" wrote: I can't just "fix" your code since I don't know what it's supposed to be doing and I have no idea of whether or not the id's you're using would work. I'd suggest getting a good beginners book on Outlook programming, like Sue Mosher's book, and learning what you're doing from that. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... It is Outlook 2003. No I have not stepped through the code. I don't know how to do that. I'm pretty sure the Entry ID's are valid. I used a code someone else gave me that retrieves the entry id for the folder. No, I don't realize that olmailitem is null. I don't know what you mean when you say "Move is a function". I don't understand what you are saying about NameSpace. I am a novice. I know how to copy code that people give me, and maybe manipulate some basic things. Other than that, I don't understand VBA. So if you could fix the code for me that would help. Thanks. |
#7
|
|||
|
|||
![]()
I know what you want to do, but I'm not going to write your code for you.
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... Well, unfortunately, I don't have the time to study up on the subject. I thought I had explained what I was trying to do, but let me try again. I want to be able to create a task in Outlook 2003 for certain email messages based a certain criteria. The scenario is this. I am going to send a message to someone and want to make sure to follow up on what I ask them to do. So when I send the message, I also send a blind copy to myself, by entering my name in the BCC field. When this message is delivered to my inbox, I would like for the system to automatically recognize that this is an email with my name in the BCC field. Then to use that message to create a task. For the task, I want the following things to happen. 1) Copy the original message into the body of the Task 2) Copy the name from the "To" field of the message into the subject line of the Task 3) Then to copy the subject of the email message and put it in the subject of the Task, after the name from # 2. 4) I want to populate the category field with the text "@Waiting". 5) I want to move the original email to a reference folder that I have. ( which is where the entry ID comes from. I know this entry ID is correct because I have other macros that move messages to this folder that work). I hope this gives a better idea of what I'm trying to do. |
#8
|
|||
|
|||
![]()
On Jan 12, 4:23*pm, "Ken Slovak - [MVP - Outlook]"
wrote: I know what you want to do, but I'm not going to write your code for you. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm "Murphybp2" wrote in message ... Well, unfortunately, I don't have the time to study up on the subject. *I thought I had explained what I was trying to do, but let me try again. I want to be able to create a task in Outlook 2003 for certain email messages based a certain criteria. *The scenario is this. *I am going to send a message to someone and want to make sure to follow up on what I ask them to do. *So when I send the message, I also send a blind copy to myself, by entering my name in the BCC field. * When this message is delivered to my inbox, I would like for the system to automatically recognize that this is an email with my name in the BCC field. *Then to use that message to create a task. For the task, I want the following things to happen. 1) Copy the original message into the body of the Task 2) Copy the name from the "To" field of the message into the subject line of the Task 3) Then to copy the subject of the email message and put it in the subject of the Task, after the name from # 2. 4) I want to populate the category field with the text "@Waiting". 5) I want to move the original email to a reference folder that I have. *( which is where the entry ID comes from. *I know this entry ID is correct because I have other macros that move messages to this folder that work). I hope this gives a better idea of what I'm trying to do.- Hide quoted text - - Show quoted text - Oh, ok then. You should have just said that in the first place rather than lie about it. Thanks for the help....or lack there of. So much for the concept of sharing knowledge on the internet. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Automatically send email for a recurring task? | jimstolz76 | Outlook - General Queries | 1 | March 23rd 07 03:35 PM |
2 simple macros - create task from email and move email to folder | [email protected] | Outlook and VBA | 5 | February 4th 07 10:57 AM |
Automatically Initialize a Field when a New Task is Created? | [email protected] | Outlook - General Queries | 1 | November 23rd 06 08:37 PM |
Automatically Create New Email When Last Recipient Approves or Acc | BenL712 | Outlook - Using Forms | 0 | September 1st 06 08:40 PM |
In a network. Can a TASK automatically tranfered to other comps? | Extra | Outlook - Using Contacts | 1 | July 1st 06 07:01 PM |