Solved

TaskItem.Body in Outlook only returns unformatted text

Posted on 2009-07-08
5
400 Views
Last Modified: 2012-05-07
I am trying to send data of a task when it is updated to a catch all email address so that we can all stay on top of task updates.
The inspector window etc is all working well, the only problem I have is that when the email is created the line breaks of the notes are not sent out.
It just looks like one big long line of text so it is not easy to discern what is the latest comment.

I can post the whole code for you if needed but this is what I am doing in short:
(The reason it looks a little bit funky is one because I have cut out loads of dimming of names and two because this is a business project with Business Contact Manager, its parent is still Task though so you can just think of it as a task).

Thanks Ed.
Private Sub project_Write(Cancel As Boolean)

Dim projectNotes As String

projectNotes = project.Body

If originalprojectNotes <> projectNotes Then

        originalprojectNotes = projectNotes

        Set mail = Application.CreateItem(olMailItem)

        mail.Subject = "" & project.Subject & " notes have been updated"

        mail.HTMLBody = "<font face='arial' colour='#000080' size='2'><p>" & project.Subject & " has been updated. The current notes are:</p><p> " & projectNotes & "</p>><p><font size = '1'>V. 1 - /4501/</p>"

        mail.To = "edmacey@iptdesign.co.uk"

        mail.Send

        End If

Open in new window

0
Comment
Question by:edmacey
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24804784
Hi, Ed.

Use the Replace function to convert the returns to HTML <br> tags.  Something like this


Private Sub project_Write(Cancel As Boolean)

Dim projectNotes As String

projectNotes = project.Body

If originalprojectNotes <> projectNotes Then

        originalprojectNotes = projectNotes

        Set mail = Application.CreateItem(olMailItem)

        mail.Subject = "" & project.Subject & " notes have been updated"

        mail.HTMLBody = "<font face='arial' colour='#000080' size='2'><p>" & project.Subject & " has been updated. The current notes are:</p><p> " & Replace(projectNotes, vbCrLf, "<br>") & "</p>><p><font size = '1'>V. 1 - /4501/</p>"

        mail.To = "edmacey@iptdesign.co.uk"

        mail.Send

        End If

Open in new window

0
 

Author Comment

by:edmacey
ID: 24805029
Once again sir, you are a genius. That has worked fantastically. Thanks Ed.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24805702
Thanks and you're welcome.
0
 

Author Closing Comment

by:edmacey
ID: 31601150
Sorry I though tmy genius comment was me accepting it, i;m doing far too many things at once. Thanks again. Ed.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24809040
No problem, Ed.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Outlook Free & Paid Tools
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now