E-mail HTML

N

Nick T

Hi,
Trying to get a little more advanced with the e-mail function recently added
to my db (with the help of this forum)! Ill keep this as brief as i can:

Iv got a continuous form which gets its data from a query. This displays
customers and their e-mail addresses. I have the following code behind a cmd
button on this form which automatically sends an e-mail to those customers
displayed on my form. One of my text boxes on the form (text27) gets its
data from another table, for which i want to put some HTML code in. As you
see in my vb code, 'text27' is the .Body of the e-mail i will send.
However, somthing is not right - what is displayed in 'text27' is simply
transferred to my e-mail as straight text, and not HTML - is there any proper
way i could do this??
My code as currently stands is:

Private Sub Command18_Click()
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strEMails As String
Dim i As Integer

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

strEMails = ""

With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If

For i = 1 To .RecordCount
If strEMails <> "" Then strEMails = strEMails & "; "
If Len(.EmailAddress) > 0 Then
strEMails = strEMails & .EmailAddress
End If
.MoveNext
Next i
End With

With objEmail
.To = strEMails
.Subject = "Hello this is a test"
.Body = Me.Text27

.Send

End With

Exit_Here:
Set objEmail = Nothing
Set objOutlook = Nothing
Exit Sub

Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here

End Sub


As always, any help greatly appreciated.
Many thanks
 
N

ND Pard

In Lieu Of:

.Body = Me.Text27

Try Something Like This:

..HTMLBody = "<p><font color=""#FF0000""><b><i><fon face=""Courier New"">" & _
"This</font></i></b> is <font size =""14""><font
color=""#0000FF"">blue</font size></font></p>"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top