Send email add message text (1 Viewer)

cktcPeterson

New member
Local time
Today, 05:03
Joined
Mar 23, 2022
Messages
12
I have a command button and onclick

I want to email a report and add a message text.
In a macro I can only do 1 line of text. I would like to add a message.

This is part of what I have played with. But only the first line shows up.

=[Parent Name] & “,”

“Congratulations! Knik Tribe is pleased to award” & “ “ & [Student Name] & “with a” & “ “ & [AwardAmount] & “scholarship from the CHOICES Program for the new grant year. This scholarship is effective Nov 1, 2021- Sept 30, 2022. There is a new two-step process when families first apply for the CHOICES Program for this grant year. You have completed the first step of registering & “ “ & [Student Name] & “, in the CHOICES Program.”



Also, I am emailing an attachment of their statement.
Object Type: Report
Object Name: rptStatement
Output: PDF
To: =([Parent Email Address])
Subject: ="CHOICES" & " " & [Student Name] & " Requested Course Approval"
Message Text: This is where I am stuck
Edit Message: Yes
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:03
Joined
Aug 30, 2003
Messages
35,743
You need to concatenate that bit onto the end of the first line, or use line continuation characters. Concatenate vbCrLf into the string for new lines.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:03
Joined
Oct 29, 2018
Messages
19,172
Have you tried using new line characters?

Chr(13) & Chr(10)

Edit: Oops, too slow...
 

cktcPeterson

New member
Local time
Today, 05:03
Joined
Mar 23, 2022
Messages
12
No. I am not familiar with that. Are you able to assist with helping me navigate that? Also what is a template file? I am searching for that as well.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:03
Joined
Aug 30, 2003
Messages
35,743
I haven't used template files. I meant:

=[Parent Name] & “,” & vbCrLf & vbCrLf & “Congratulations! Knik Tri..."

I get mixed up on when that works vs the Chr() method. Also, if you want bold and such you'd need to use HTML tags instead of either of those. I would use a string variable as well.
 

Sarah.M

Member
Local time
Today, 16:03
Joined
Oct 28, 2021
Messages
303
Message Text: This is where I am stuck
Try to Connect this Message Text argument to the Long Text or Text Box control
Message Text: =[Forms]![FormName]![Text Box]
Anything you type inside this text box will appear on your Outlook page
 

LGDGlen

Member
Local time
Today, 14:03
Joined
Jun 29, 2021
Messages
221
Multi line messages can be built in HTML like this

Code:
    Dim OutApp As Object, OutMail As Object, greeting As String, HtmlContent As String, subjectLine As String, attachmentFileName As String
    Dim folderSelected as String
    Set OutApp = CreateObject("Outlook.Application"): Set OutMail = OutApp.CreateItem(0)

        If Time() < 0.5 Then greeting = "Good Morning,"
        If Time() > 0.5 And Time() < 0.75 Then greeting = "Good Afternoon,"
        If Time() > 0.75 Then greeting = "Good Evening,"
        With OutMail
            .To = "person@company1.com"
            .CC = "person@company2.com"
            .Subject = "Subject text"
            .HTMLBody = "<font face='calibri'>" & greeting & "<br><br>Hello there<br><br>another line<br><br>"
            .Attachments.Add folderSelected & "\" & attachmentFileName
            'can be olImportanceNormal, olImportanceHigh or olImportanceLow
            .Importance = olImportanceHigh
            ' Display will open message, or send will send it
            '.Display True
            '.Send
        End With

ignore me i just realised this is in a macro and not a VBA event code :( not quite awake yet
 

Users who are viewing this thread

Top Bottom