View Single Post
 
Old 09-24-2017, 05:56 PM
russkris russkris is offline Windows 8 Office 2016
Novice
 
Join Date: Sep 2017
Location: Hobart, Tasmania, Australia
Posts: 3
russkris is on a distinguished road
Default Adding document fields to subject line of email

Hi Guys,

I have a small form and added an email button to assist clients to submit it easier and to structure the subject lines

Code:
Private Sub CommandButton1_Click()
Dim OL              As Object
Dim EmailItem       As Object
Dim Doc             As Document
 
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
 
With EmailItem
    .Subject = "SUBJECT LINE"
    .Body = "BODY MESSAGE" & vbCrLf & _
    "SECOND LINE BODY MESSAGE" & vbCrLf & _
    "THIRD LINE BODY MESSAGE"
    .To = "TEST@EMAIL.COM"
    .Importance = olImportanceNormal
    .Attachments.Add Doc.FullName
    .Display
    
End With
 
Application.ScreenUpdating = True
 
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
    
End Sub

I am new to VBA, so I really don't know what I am doing and used google to help.

What I want to do is use information users enter. So I have a uch of content controls for example "date1, commodity, location" etc.

Is there a way I can use the information entered into the fields to form a subject line?
Reply With Quote