Solved

TaskItem.Body in Outlook only returns unformatted text

Posted on 2009-07-08
5
396 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

21 Experts available now in Live!

Get 1:1 Help Now