473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

One outlook email not displaying HTML formatted message?

XP SP2, access and outlook 2003

I have a form with 3 command buttons on that when one is pressed it opens up a html email for the user to send. Two of the emails work fine and open with the full colour and size formatted text but one of them just shows the html code in the body with no formatting.

The vba code for the command button is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdateEmail_Click() 
  2. Dim HTMLReminderEmail As String 
  3. Dim Subject As String 
  4. Dim objOutlook As Outlook.Application 
  5. Dim objOutlookMsg As Outlook.MailItem 
  6. Dim RefNo As Integer 
  7.  
  8. Set conn = New ADODB.Connection
  9.  ' Specify the OLE DB provider. 
  10. conn.Provider = "sqloledb" 
  11.  
  12. ' Set SQLOLEDB connection properties. 
  13. conn.Properties("Data Source").Value = "PPE-DB2" 
  14. conn.Properties("Initial Catalog").Value = "Live_Service" 
  15.  
  16. 'Windows NT authentication. 
  17. conn.Properties("Integrated Security").Value = "SSPI" 
  18.  
  19. ' Open the database. 
  20. conn.Open 
  21.  
  22. RefNo = Me.txtRefNo 
  23. Set rs1M = New ADODB.Recordset 
  24. rs1M.Open "Select * from _1MIncidents WHERE [RefNo] = " & RefNo, conn, adOpenDynamic, adLockOptimistic 
  25. 'Create the application 
  26. Set objOutlook = CreateObject("Outlook.Application") 
  27. Create the mail item 
  28. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) 
  29.  
  30. 'HTMLReminderEmail = "<HTML><Font Face = " & Chr(34) & "Arial" & Chr(34) & "><Font color = " & Chr(34) & "Blue" & Chr(34) & "><Font Size = " & Chr(34) & "3" & Chr(34) & ">All,<br><br>The problem has been identified,</font color></font size><font color = " & Chr(34) & "Red" & Chr(34) & "><Font Size = " & Chr(34) & "4" & Chr(34) & ">Please do not attempt to use " & rs1M![systemArea] & " until further notice.<br><br></font color></font size><Font color = " & Chr(34) & "Blue" & Chr(34) & "><Font Size = " & Chr(34) & "3" & Chr(34) & ">The Business Systems Team are working to return normal service ASAP.</Font Size></Font Color></Font></HTML>" 'HTMLReminderEmail = "<HTML><body><font face = " & Chr(34) & "Arial" & Chr(34) & "><font size = " & Chr(34) & "2" & Chr(34) & "><font color = " & Chr(34) & "Blue" & Chr(34) & ">All, <br><br>The Problem has been identified, </font color></font size><font size = " & Chr(34) & "3" & Chr(34) & "><font color = " & Chr(34) & "Red" & Chr(34) & ">Please do not attempt to use " & rs1M![systemArea] & " until further notice.<br><br></font color></font size><font size = " & Chr(34) & "2" & Chr(34) & "><font color = " & Chr(34) & "Blue" & Chr(34) & ">The Business Systems Team are working to return normal service ASAP.</font color></font size></font face></font></body></HTML>" 'MsgBox HTMLReminderEmail HTMLReminderEmail = "<HTML><Font Face = " & Chr(34) & "Arial" & Chr(34) & "><Font color = " & Chr(34) & "Blue" & Chr(34) & "><Font Size = " & Chr(34) & "3" & Chr(34) & ">All,<br><br>The problem has been identified,<font color = " & Chr(34) & "Red" & Chr(34) & "><Font Size = " & Chr(34) & "4" & Chr(34) & ">Please do not attempt to use " & rs1M![systemArea] & " until further notice.<br><br></font color></font size>The Business Systems Team are working to return normal service ASAP.</Font Size></Font Color></Font></HTML>" 
  31.  
  32. Subject = rs1M![systemArea] & " Error" 
  33.  
  34. With objOutlookMsg 
  35.     .To = "Matthew.Bradshaw@prepol.com" 
  36.     .Subject = Subject 
  37.     .body = HTMLReminderEmail 
  38.     .BodyFormat = olFormatHTML 
  39.     .Display 
  40. End With rs1M![LastEmailed] = DateTime.Now rs1M.Update
The html code produced is

"<HTML><Font Face = "Arial"><Font color = "Blue"><Font Size = "3">All,<br><br>The problem has been identified,<font color = "Red"><Font Size = "4">Please do not attempt to use Syteline until further notice.<br><br></font color></font size>The Business Systems Team are working to return normal service ASAP.</Font Size></Font Color></Font></HTML>"

When the html is put in a notepad file and saved as a html document it displays correctly, but for some reason outlook is not picking up the html for this email.

Thanks in advance Matt
Sep 4 '08 #1
1 4554
Never mind just realised in the objoutlookmessage with should e .htmlbody not .body.

Spent about 2 hours trying to get this to work.
Sep 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
1
by: Deepak Bhatia | last post by:
Hello Friends I wrote a simple VB application using Outlook Object Model. This application is used t send mail via MS Outlook. I wrote following code on Send button: Set mailitem =...
4
by: Fred | last post by:
I want to insert DHL and FedEx tracking links with the waybill numbers in the body of emails I am sending using sendobject. I am not sending attachments. DHL and FedEx use long links that...
2
by: Eric Peterson | last post by:
I need to pop up the send email form from Outlook. I also need to populate the to field, but obviously the user will type the message and hit 'SEND'. How can I do this? I've been through...
10
by: John | last post by:
Hi When I open a new outlook email from vb.net, sometimes outlook is very slow to appear or occasionally outlook freezes completely. I am targeting mixed office2000/xp environments so I am...
2
by: Siv | last post by:
Hi, I have written an application which is used by sales staff when discussing products with their customers over the phone. It is a database application that holds detailed information about...
6
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
0
by: mrajeshbabu | last post by:
hi this is Rajesh i am working with email concept in asp.net 2.0 i am using html formatted email and i have put in table control all the images and text
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.