简体   繁体   中英

How to change font color for updated Access data in Outlook mail

In Access 2010 I have tables, eg Employee(Pracownicy). I can update the data in the table using the subform and the update button.

Updating the data in the subform automatically generates an Outlook mail containing the data in the updated record.

I need to change font color for updated data in the mail body.

在此处输入图片说明

The code to update the data and generate e-mail:

Private Sub cmdUpdate2_Click()

CurrentDb.Execute "update Pracownicy" & _
    " SET Identyfikator='" & Me.txtID & "'" & _
    ", Imie='" & Me.txtImie & "'" & _
    ", Nazwisko ='" & Me.txtNazwisko & "'" & _
    ", Wiek ='" & Me.txtWiek & "'" & _
    ", Data_urodzenia ='" & Me.txtData & "'" & _
    ", Miejsce_urodzenia ='" & Me.txtMiejsce & "'" & _
    ", Miejscowosc ='" & Me.txtMiejscowosc & "'" & _
    ", Plec ='" & Me.txtPlec & "'" & _
    " where Identyfikator='" & Me.txtID & "'"

'------------------------------------SEND EMAIL----------------------
'Dim varName As Variant
'Dim strUCC As String
Dim varSubject As Variant
Dim varBody As Variant
Dim Poczta As Object
Dim MojMail As Object

On Error Resume Next 

'varName = ""
varSubject = "Employer List "
varBody = "Hello" & _
    "<br><br>Employer List: " & _
    "<br><br><B>Identyfikator:</B>   " & Me.txtID & "  " & _
    "<br><B>Imie:</B>  " & Me.txtImie & "  " & _
    "<br><B>Nazwisko:</B>   " & Me.txtNazwisko & "  " & _
    "<br><B>Wiek:</B>   " & Me.txtWiek & "  " & _
    "<br><B>Data urodzenia:</B>   " & Me.txtData & "  " & _
    "<br><B>Miejsce urodzenia:</B>   " & Me.txtMiejsce & "  " & _
    "<br><B>Miejscowosc:</B>   " & Me.txtMiejscowosc & "  " & _
    "<br><B>Plec:</B>   " & Me.txtPlec & "  "

Set Poczta = CreateObject("outlook.application")
Set MojMail = Poczta.createitem(0)

With MojMail
    '.To =
    '.BCC =
    .subject = varSubject
    '.ReadReceiptRequested = True
    '.originatorDeliveryReportRequested = True
    .htmlbody = varBody & "<br>"
    .display
    '.send
End With

Set Poczta = Nothing
Set MojMail = Nothing

If Err.Number <> 0 Then
    MsgBox ("Atention")
End If

On Error GoTo 0 
'------------------------------------------------------------------------

DoCmd.Close

MsgBox ("End Update")

End Sub

I think this becomes more of an HTML question rather than VBA. Try adding a FONT tag to the following line and see if that works for you.

"<br><br><B><font color="red">Identyfikator:</font></B>   " & Me.txtID & "  " & _

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM