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

Create task automatically from email



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 9th 08, 11:07 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Create task automatically from email

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  
Old January 10th 08, 12:13 AM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create task automatically from email

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  
Old January 10th 08, 05:03 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Create task automatically from email

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  
Old January 10th 08, 06:05 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default Create task automatically from email

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  
Old January 10th 08, 07:23 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create task automatically from email

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  
Old January 12th 08, 09:13 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Create task automatically from email

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  
Old January 12th 08, 10:23 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create task automatically from email

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  
Old January 16th 08, 05:48 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Create task automatically from email

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
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
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


All times are GMT +1. The time now is 08:16 PM.


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.