Email Form textbox format (1 Viewer)

Trevor G

Registered User.
Local time
Today, 11:27
Joined
Oct 1, 2009
Messages
2,341
Hi everyone,
I have written code to email contents from a form to Outlook but I am having difficulty in formatting the body of the email for line of code which picks the contents up from a textbox. Like an item that has to be highlighted. Textbox content in the email should be emailed highlighting as Font name Tahoma size 14 and coloured Blue. I am aware of HTMLBODY but cant get it to recognise the textbox name to colour, such as txtItem.

I would appreciate your guidance please.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:27
Joined
May 7, 2009
Messages
19,247
can you change the Text Format property of the textbox (in design view) to Rich Text.
 

Trevor G

Registered User.
Local time
Today, 11:27
Joined
Oct 1, 2009
Messages
2,341
Hi thanks for the reply,
The whole form is unbound textboxes when emailed it picks up the contents from a query, I haven't found the property to change to rich text format. When I have tried various options the format doesn't appear in the email.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:27
Joined
May 7, 2009
Messages
19,247
so the Whole text on the textbox should be formatted as Tahoma size 14 and in blue color.
you can search "Font html tag". then you can format the textbox:

.HTMLBody = "<font face=""Tahoma"" size=14 color=""blue"">" & [TextboxName].Value & "</font>"
 

Trevor G

Registered User.
Local time
Today, 11:27
Joined
Oct 1, 2009
Messages
2,341
Thank you for this, when I developed I used the form name and text box name so it was something along the lines of

Forms!frmMail!MainText

I will look to change the code and test it. I will reply
 

Trevor G

Registered User.
Local time
Today, 11:27
Joined
Oct 1, 2009
Messages
2,341
Just tried implementing and it highlights the textbox name in the square brackets, if you don't mind I am indicating the code below and showing a screen shot of the form and error message it highlights. Would you be kind enough to take a look and make any suggestions?

Sub SendMessages()
'Set the reference to use Microsoft Outlook
'Select the Tools Menu and Refereneces
'Search down for Microsoft Outlook XX.Object Library (XX is the version number you are using
Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim ToAddress As String
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("qryEMailList")
MyRS.MoveFirst
' Open Outlook
Set objOutlook = CreateObject("Outlook.Application")

Do Until MyRS.EOF
'Create each email
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
ToAddress = MyRS!
With objOutlookMsg
' Add the To recipients to the e-mail message.
Set objOutlookRecip = .Recipients.Add(ToAddress)
objOutlookRecip.Type = olTo
' Set the Subject, the Body, and the Importance of the e-mail message.
.To = ToAddress
.Subject = Forms!frmMail!Subject
.Body = Forms!frmMail!MainText
'.HTMLBody = "<font face=""Tahoma"" size=14 color=""blue"">" & [MainText].Value & "</font>"
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display 'comment this line to send once checked
'.Send remove the comment to send once checked
End With
MyRS.MoveNext
Loop
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
 

Attachments

  • Welcome.jpg
    Welcome.jpg
    23.7 KB · Views: 88
  • Not.jpg
    Not.jpg
    65.1 KB · Views: 86

Trevor G

Registered User.
Local time
Today, 11:27
Joined
Oct 1, 2009
Messages
2,341
Sorted the issue. Thank you I wouldn't have got near a solution without your help.

Line adjusted to

.HTMLBody = "<font face=""Tahoma"" size=14 color=""blue"">" & Forms!frmMail!MainText.Value & "</font>"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:27
Joined
May 7, 2009
Messages
19,247
glad you figured it out!
 

Users who are viewing this thread

Top Bottom