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

VBA Script that copies incoming message to task



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 3rd 08, 07:05 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default VBA Script that copies incoming message to task

I am trying to create a process where when I send a message that I
want to be sure to follow up on, I cc myself on the message. I want
to then take that incoming message, copy it to a task and populate
certain fields on the task, then delete the message. I am currently
trying to run the script after a rule identifies the message. If
there is a better way of doing it, I'm open to suggestions. Below is
the script I have, but it's not working, and I can't figure out what
the problem is. Any help would be appreciated.


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 3rd 08, 07:17 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default VBA Script that copies incoming message to task

What specifically isn't working?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Murphybp2" wrote in message ...
I am trying to create a process where when I send a message that I
want to be sure to follow up on, I cc myself on the message. I want
to then take that incoming message, copy it to a task and populate
certain fields on the task, then delete the message. I am currently
trying to run the script after a rule identifies the message. If
there is a better way of doing it, I'm open to suggestions. Below is
the script I have, but it's not working, and I can't figure out what
the problem is. Any help would be appreciated.


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 3rd 08, 09:46 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default VBA Script that copies incoming message to task

You could use the ItemSend event to grab a copy of the message and
copy it to your default Tasks folder (which would turn it into a
task).

For example:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim objNS As NameSpace
Dim TaskFldr As MAPIFolder
Dim recip As Recipient

Set objNS = Application.GetNamespace("MAPI")
Set TaskFldr = objNS.GetDefaultFolder(olFolderTasks)

If TypeName(Item) = "MailItem" Then
Set Msg = Item
For Each recip In Msg.Recipients
If recip.Name = "Jimmy Pena" Then
Set mymsg = Msg.Copy
mymsg.Move TaskFldr
End If
Next recip
End If


HTH,
JP

On Jan 3, 2:05*pm, Murphybp2 wrote:
I am trying to create a process where when I send a message that I
want to be sure to follow up on, I cc myself on the message. *I want
to then take that incoming message, copy it to a task and populate
certain fields on the task, then delete the message. *I am currently
trying to run the script after a rule identifies the message. *If
there is a better way of doing it, I'm open to suggestions. *Below is
the script I have, but it's not working, and I can't figure out what
the problem is. *Any help would be appreciated.

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


 




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
Creating an Outlook Task with VB Script Pegasus \(MVP\) Outlook and VBA 3 November 28th 07 10:06 PM
Task shortcuts (not copies of Tasks) in Calendar Appointments (for the Microsoft Office development team) Mark Davies Outlook - General Queries 2 February 14th 07 03:48 PM
How do I script to change the subject line of incoming mail? D-Man Outlook and VBA 3 January 29th 07 07:12 PM
script to clear out categories on incoming emails [email protected] Outlook and VBA 2 July 31st 06 07:17 PM
Receive multi-copies of incoming emails? wendystation Outlook - Using Contacts 9 May 3rd 06 02:27 PM


All times are GMT +1. The time now is 03:35 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.