Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TaskItem.Body in Outlook only returns unformatted text

Posted on 2009-07-08
5
Medium Priority
?
427 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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
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…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

618 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