this is the complete code I was testing
Code:
Private Sub Submit_Click()
Dim test, str, strFName, strdate, strFilename, strFileA, strFileB, strFileC As String, aCC As ContentControl, Doc As Document
strFName = Left(ActiveDocument.SelectContentControlsByTitle("FirstName")(1).Range.Text, 4)
str = strFName & Left(ActiveDocument.SelectContentControlsByTitle("LastName")(1).Range.Text, 4)
strdate = Format(Now, "yyyymmddhhm")
Set aCC = ActiveDocument.SelectContentControlsByTitle("PhoneC")(1)
If aCC.ShowingPlaceholderText Then
'need code to check PhoneC here
Else
str = str & Right(aCC.Range.Text, 4)
strFilename = str & "_" & strdate
End If
strFileA = strFilename
strFileB = "C:\Users\SR\OneDrive\Documents\FormProject2024\Fillable\From scratch\pdf\" & strFileA
ActiveDocument.SaveAs FileName:=strFileB, Fileformat:=wdFormatPDF, AddToRecentFiles:=False
Dim sender_email, email_message, email_message2, reply_address, sender_name As String
Dim Mail As New Message
Dim Cfg As Configuration
On Error GoTo Error_Handling
Set Cfg = Mail.Configuration
'SETUP MAIL CONFIGURATION
Cfg(cdoSendUsingMethod) = cdoSendUsingPort
Cfg(cdoSMTPServer) = "smtp.gmail.com"
Cfg(cdoSMTPServerPort) = 587
Cfg(cdoSMTPAuthenticate) = cdoBasic
Cfg(cdoSMTPUseSSL) = True
Cfg(cdoSendUserName) = "vbatestingtest@gmail.com"
Cfg(cdoSendPassword) = "coding123$$"
Cfg.Fields.Update
'SEND EMAIL
With Mail
.From = "vbatestingtest@gmail.com"
.ReplyTo = "vbatestingtest@gmail.com"
.To = "shellreid2004@yahoo.ca"
.CC = "disegnifenice@gmail.com"
.BCC = " "
.Subject = "testing form send"
.HTMLBody = "testing"
.AddAttachment (strFileB)
.Send
End With
Error_Handling:
If Err.Description <> "" Then MsgBox Err.Description
End Sub