HTML Email (1 Viewer)

Aimn_4U

Registered User.
Local time
Today, 21:21
Joined
May 14, 2019
Messages
33
Hi All,

I have written a code on a button to automatically put details from my database into an email.
I had the code working, however I was not able to format any of it, and from research I believe it is because I did not have it in HTML format.
I have changed my code to HTML, however now it is not pulling the actual data and instead is just leaving it as (Example) & Me.Internal_Unit_Code.
I have popped the code below, if anyone is able to tell me where I am going wrong (Again :banghead:) It would be greatly appreciated.

Private Sub Send_for_Review_Click()
Dim appOutlook As New Outlook.Application
Dim objEmail As Outlook.MailItem
Set objEmail = appOutlook.CreateItem(olMailItem)
With objEmail
.BodyFormat = olFormatHTML
.HTMLBody = "Dear < br <> br > Please see below details of a precedent that requires your review.<br><br>Attached is the documentation that was used for the previous assessment of this precedent.<br><br><b>Internal Unit Code:</b> & [Me.Internal_Unit_Code]<br><b>Internal Unit Title:</b> & Me.Internal_Unit_Title<br><b>External Unit Code:</b> & Me.External_Unit_Code<br><b>External Unit Title:</b> & Me.External_Unit_Title <br><b>External Institution:</b> & Me.External_institution<br><b> Precedent Linked to specific course, Major and/Or Stream:</b> & Me.Course_Major_Stream_Code<br><b>Years/s basis unit was complete:</b> & Me.Year_s_Basis_Unit_Completed<br><b> Previously assessed by:</b> & Me.Precedent_assessed_by <br><b> Date of last assessment: </b> & Me.Date_Assessed <br><br> If you could please review this precedent and return the outcome to us within 5 working days"
.Display

End With
End Sub
 

June7

AWF VIP
Local time
Today, 05:21
Joined
Mar 9, 2014
Messages
5,466
For future, please post code between CODE tags to retain indentation and readability.

Need to concatenate variables. Missing a bunch of quote marks. Use line continuation character.
Code:
    .HTMLBody = "Dear someone, <br><br>" & _
        "Please see below details of a precedent that requires your review.<br><br>" & _
        "Attached is the documentation that was used for the previous assessment of this precedent.<br><br>" & _
        "<b>Internal Unit Code: </b>" & Me.Internal_Unit_Code & "<br>" & _
        "<b>Internal Unit Title: </b>" & Me.Internal_Unit_Title & "<br>" & _
        "<b>External Unit Code: </b>" & Me.External_Unit_Code & "<br>" & _
        "<b>External Unit Title: </b>" & Me.External_Unit_Title & "<br>" & _
        "<b>External Institution: </b>" & Me.External_institution & "<br>" & _
        "<b>Precedent Linked to specific course, Major and/Or Stream: </b>" & Me.Course_Major_Stream_Code & "<br>" & _
        "<b>Years/s basis unit was complete: </b>" & Me.Year_s_Basis_Unit_Completed & "<br>" & _
        "<b>Previously assessed by: </b>" & Me.Precedent_assessed_by & "<br>" & _
        "<b>Date of last assessment: </b>" & Me.Date_Assessed & "<br><br>" & _
        "If you could, please review this precedent and return the outcome to us within 5 working days."
 
Last edited:

Aimn_4U

Registered User.
Local time
Today, 21:21
Joined
May 14, 2019
Messages
33
Hi June7,
Thank you very much for your response. I had been trying to format it correctly with no luck (I am very new to this). Thank you so much for your assistance.

I was wondering if you are also able to tell me where I would put the code to change the font that the email is in ?

Thank you
 

Aimn_4U

Registered User.
Local time
Today, 21:21
Joined
May 14, 2019
Messages
33
Hi June7,
I managed to change the font to the one I wanted :p:)

Thanks again for all your help
 

Users who are viewing this thread

Top Bottom