Kemidan2014
Board Regular
- Joined
- Apr 4, 2022
- Messages
- 229
- Office Version
- 365
- Platform
- Windows
I keep getting a compile error when i added some font formating conditions to my msg string. I have tried different examples i have seen from google search. I believe its probably something as simple as I am not putting quotes, parenthesis or & in the correct spots.
I have a simple message I constructed for an email that we want to send out through Access.
All i want to do is just have the font size be 22pt in the body of the email
This is my original String set up. this worked but puts it in my emails default font size and font type.
Below is the current code where i attempted to add Font size format. but the bottom 2 lines go red and give me the compile error.
I have a simple message I constructed for an email that we want to send out through Access.
All i want to do is just have the font size be 22pt in the body of the email
This is my original String set up. this worked but puts it in my emails default font size and font type.
Code:
msg = "Team," & ""<br><br>" & "The following issue needs to be corrected:" & "<br><br>" & _
Me.[Program] & " " & Me.[Product] & " from Line" & Me.[Line #] & " " & Me.ProcessID & " has a " & Me.[Abnormal Condition] & " abnormal condition." & "<br><br>" & _
"Target should be "& Me.[Tolerance] & " Actual result was " & Me.[Actual] & "." 'define email message
Below is the current code where i attempted to add Font size format. but the bottom 2 lines go red and give me the compile error.
Code:
Private Sub Command258_Click()
Dim O As Outlook.Application 'Declare outlook object
Dim M As Outlook.MailItem 'Declare mail object
Dim db As DAO.Database 'declare database variable
Dim rst As DAO.Recordset ' declare recordset variable
Dim address As String 'declare string name for email
Set db = CurrentDb 'set the database
Set rst = CurrentDb.OpenRecordset("Select Email From emaillist Where Hotzone = '" & Me.hotzone & "'") 'set recordset for email recipients with SQL query
Dim msg As String 'declare variable is a string statement for email message
msg = "<body style=Font-size:22pt> Team, & <br><br> & The following issue needs to be corrected: & <br><br> & _"
"<p style=font-size:22px> & Me.[Program] & & Me.[Product] & from Line & Me.[Line #] & & Me.ProcessID & has a & Me.[Abnormal Condition] & abnormal condition & <br><br> </p>" & _
"<p style=font-size:22px> Target should be & Me.[Tolerance] & Actual result was & Me.[Actual] & .</p></Body>" 'define email message
Set O = New Outlook.Application 'set the outlook object
Set M = O.CreateItem(olMailItem) 'set the mail item
'Procedure to generate a multirecipient email string
With rst
Do While Not .EOF
'If rst!hotzone = Me.hotzone Then
address = address & rst!Email & ";"
rst.MoveNext
'End If
Loop
End With
Debug.Print address
'procedure to create the email and send or display it
With M
.To = address
.BodyFormat = olFormatHTML
.HTMLBody = msg
.Subject = "Attention Out of Spec Condition " & Me.[Program] & " " & Me.[Product]
'.Send
.Display
End With
'MsgBox "E-mail has been sent!", vbOKOnly
Set rst = Nothing 'empty the memory
Set M = Nothing
Set O = Nothing
End Sub