Solved

TaskItem.Body in Outlook only returns unformatted text

Posted on 2009-07-08
5
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

724 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