![]() |
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
|
|||
|
|||
![]()
Hi guys,
I've written a script that creates a task from a selected email. It puts the body of the email into the body of the task, but I also wanted it to include a "reference" to the original email (like that message icon perhaps) so I can link back to it. Anyone know how to do this? Here's the code: ----------- Sub TaskFromEmail() Dim item As MailItem Set item = Outlook.Application.ActiveExplorer.Selection.item( 1) Dim olApp As Outlook.Application Dim olTsk As TaskItem Dim userField As Outlook.UserProperty Dim userName As String Set olApp = New Outlook.Application Set olTsk = olApp.CreateItem(olTaskItem) With olTsk .Subject = item.Subject .Status = olTaskNotStarted 'Need to insert reference to the original email in the new task so I can link back to it ' ".Body = item" ' didn't work, neither did ".Attachments.Add item" 'Remove formatting item.BodyFormat = olFormatPlain .Body = Replace(item.Body, " " & vbCrLf, vbCr) .Save End With Set olTsk = Nothing Set olApp = Nothing End Sub ----------- P.S. -- You can see that I am removing formatting and attempting to remove extra line breaks. This is because I was getting all kinds of extra line breaks when copying the body from the email to the task. Any way to keep the formatting but lose extra line breaks? |
Ads |
#2
|
|||
|
|||
![]()
Use the TaskItem.Attachments.Add method using olEmbeddedItem for the Type parameter.
FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/comm....program_v ba -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Steve Newhouse" wrote in message oups.com... Hi guys, I've written a script that creates a task from a selected email. It puts the body of the email into the body of the task, but I also wanted it to include a "reference" to the original email (like that message icon perhaps) so I can link back to it. Anyone know how to do this? Here's the code: ----------- Sub TaskFromEmail() Dim item As MailItem Set item = Outlook.Application.ActiveExplorer.Selection.item( 1) Dim olApp As Outlook.Application Dim olTsk As TaskItem Dim userField As Outlook.UserProperty Dim userName As String Set olApp = New Outlook.Application Set olTsk = olApp.CreateItem(olTaskItem) With olTsk .Subject = item.Subject .Status = olTaskNotStarted 'Need to insert reference to the original email in the new task so I can link back to it ' ".Body = item" ' didn't work, neither did ".Attachments.Add item" 'Remove formatting item.BodyFormat = olFormatPlain .Body = Replace(item.Body, " " & vbCrLf, vbCr) .Save End With Set olTsk = Nothing Set olApp = Nothing End Sub ----------- P.S. -- You can see that I am removing formatting and attempting to remove extra line breaks. This is because I was getting all kinds of extra line breaks when copying the body from the email to the task. Any way to keep the formatting but lose extra line breaks? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2007 Task Form Insert Ribbon (Attach Group) | [email protected] | Outlook - General Queries | 9 | April 26th 07 07:38 PM |
Can I insert tabs or change margin in my Task-Microsoft Outlook? | [email protected] | Outlook - General Queries | 1 | December 15th 06 12:07 AM |
insert as text (to insert html into email body) | Iona | Outlook - General Queries | 1 | July 13th 06 12:10 PM |
Cannot Insert Item into a task occasionally - Outlook 2003 | [email protected] | Outlook - General Queries | 1 | May 10th 06 04:47 AM |
How do I insert a clipart item in task reminders? | Sue Mosher [MVP-Outlook] | Outlook - Using Forms | 0 | February 6th 06 08:12 PM |