I created a form and would like to send an email using a button capturing data from the sub-form (based on a query).
I am using this YouTube video as a guide and get stuck (starting from msg =...
.
Private Sub cmd_EmailContact_Click()
Dim Msg As String
msg = "Dear " & First name & ",<P>" & _
Student First name & "has been successfully been loaded on the platform" & ",<P>" & _
"Student login details on the platform are:" & ",<P>" & _
"Username:" & Username & ",<P>" & _
"Password:" & Password**
Dim O As Outlook.Application
Dim M As Outlook.MailItem
Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)
With M
.BodyFormat = olFormatHTML
.HTMLBody = Msg
.To = Email
.Subject = "Student available on OARS"
.Display
End With
Set M = Nothing
Set O = Nothing
End Sub
Variables are populated on a query on the form.
First name (Name of teacher)
Student First name
Username
Password
` in your string means "paragraph" in HTML, which translates to "new line in the email". (kinda a sloppy way to do it, but it will work) - an alternative would be to use `
– braX Sep 30 '21 at 05:15` instead. so try this next `Msg = "Test
Test2
Test3"` and notice what that does to see what i mean.