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

Creating Task from Email -- How can I Link Back to Original Email?



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old July 19th 07, 04:36 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating Task from Email -- How can I Link Back to Original Email?

You can use HTML to include a URL to an Outlook item by using the EntryID
value for that item. The URL would look something like this:

outlook:0000000038F2773A1C598D49882D14EC0C5C40C307 005097C3A46725204AA35E65B312CAAC8F0000003D6E3F0000 C89D644618E4C8408094239F8819D4700000015149620000

Keep in mind that if the item is moved the EntryID value will change.

BTW, I'm not sure why your message body is messed up. Are you setting the
body by using DestinationItem.Body = SourceItem.Body? Try
DestinationItem.Body = SourceItem.HTMLBody as well.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Steve Newhouse" wrote:

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


 




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
Link to original item Jason Kaler Outlook - Using Forms 0 April 20th 07 11:44 AM
What happens to the original email when it gets made into a task? [email protected] Outlook - General Queries 3 January 29th 07 06:21 AM
Creating a link to an e-mail in a task [email protected] Outlook and VBA 1 November 14th 06 06:03 AM
link task or email to contact in outlook 2007 mikem Outlook - Using Contacts 4 September 18th 06 10:59 PM
automatically delted email after clicking a link in email? drone1 Outlook - Installation 1 June 27th 06 07:27 PM


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