View Single Post
  #1  
Old July 18th 07, 09:19 PM posted to microsoft.public.outlook.program_vba
Steve Newhouse
external usenet poster
 
Posts: 2
Default Creating Task from Email -- How can I Link Back to Original Email?

Hi guys,

I wrote the script below to create a Task from the selected email. I
want to be able to include a link back to the original email in the
body of the task. Is there a way to do this?

Thanks,
Steve

P.S. -- As you can see, I'm trying to remove extra line breaks (but
have to switch to plain text format) because when I copy from the body
of the email to the body of the task, it gets all spaced out.. It
works OK but sometimes still looks bad... Is there any way to make it
look exactly the same in the body of the task as it does in the
original email?

---------

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

item.BodyFormat = olFormatPlain
.Body = Replace(item.Body, " " & vbCrLf, vbCr)

.Save

End With

Set olTsk = Nothing
Set olApp = Nothing

End Sub

Ads