Hello - I have a workbook which I am using as a data entry form. The goal is, once I click the Submit button on the "Form" tab, the data will be entered into the next available row on the "Database" tab. Then an email should open and populate with details from the submitted record (only the newest submitted record).
The form works great. I am working on the email piece and am running into some errors. For every error I find a solution to it seems like I find more!
On the "Database" tab - I have used the Offset function in the Name Manager to name the range for each of the pieces of data that I need to add into the email body or subject line of the email. I feel like I just keep adding things to the code and I am not sure if they are even needed.
I want this to be dynamic. There will be only one user in the workbook entering data at any given time. The data entered into the form needs to come from the data that is currently being submitted from the form. Below is the current code I am using:
Thank you for your help!!
The form works great. I am working on the email piece and am running into some errors. For every error I find a solution to it seems like I find more!
On the "Database" tab - I have used the Offset function in the Name Manager to name the range for each of the pieces of data that I need to add into the email body or subject line of the email. I feel like I just keep adding things to the code and I am not sure if they are even needed.
I want this to be dynamic. There will be only one user in the workbook entering data at any given time. The data entered into the form needs to come from the data that is currently being submitted from the form. Below is the current code I am using:
VBA Code:
''''''''''''''''''''''''Send Email''''''''''''''''''''''''''''
Dim strDate As String
Dim Signature As String
Dim sTempPath As String
Dim OutApp As Object
Dim OutMail As Object
Dim lastRow As Range
Dim SP As Range ' Service Provider
Dim CN As Range ' Client Name
Dim CP As Range ' Client Policy
Dim ClaimN As Range ' Claim Number
Dim V As Range ' VIN
Dim PN As Range ' Phone Number
Dim JID As Range ' Job ID
Dim JT As Range ' Job Type
Dim CT As Range ' Concern Type
Dim DR As Range ' Date Received
Dim S As Range ' Synopsis
Dim cUser As String
Dim ws As Worksheet
Dim wb As Workbook
On Error GoTo Whoa
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set wb = ActiveWorkbook
Set ws = Sheets("Database").Range("A1").Select
Selection.End(xlDown).Select
SP = ActiveCell.Offset(0, 1).Value 'Service Provider
CN = ActiveCell.Offset(0, 2).Value 'Client Name
CP = ActiveCell.Offset(0, 3).Value 'Client Policy
ClaimN = ActiveCell.Offset(0, 4).Value 'Claim Number
V = ActiveCell.Offset(0, 5).Value 'VIN
PN = ActiveCell.Offset(0, 6).Value 'Phone Number
JID = ActiveCell.Offset(0, 9).Value 'Job ID
JT = ActiveCell.Offset(0, 11).Value 'Job Type
CT = ActiveCell.Offset(0, 10).Value 'Concern Type
DR = ActiveCell.Offset(0, 12).Value 'Date Received
S = ActiveCell.Offset(0, 14).Value 'Synopsis
strDate = Format(Date, "mm-dd-yy") & " @ " & Format(Time, "hh:mm AM/PM")
cUser = Environ$("Username")
sTempPath = "C:\Users\" & cUser & "\AppData\Local\Temp\"
With OutMail
.Display
End With
Signature = OutMail.HTMLBody
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Escalation" & " " & CN & " " & strDate & " " & "Audits are ready for review " & " " & JID & ""
.Body = "<body style='font-family:calibri;font-size:15'>" & "Hello," & "<br><br>" & " I am inquiring about our insured experience in reference to Job ID Number" & _
" " & JID & " " & "Please see the below details: " & "<br><br>" & _
"Client Name:" & " " & CN & "<br>" & _
"Client Policy Number:" & " " & PN & "<br>" & _
"Claim Number:" & " " & ClaimN & "<br>" & _
"VIN:" & " " & V & "<br>" & _
"Phone Number Called From:" & " " & PN & "<br>" & _
"Job ID Number:" & " " & JID & "<br>" & _
"Concern Type:" & " " & CT & "<br>" & _
"Job Type:" & " " & JT & "<br>" & _
"Date Received:" & " " & DR & "<br>" & _
"Synopsis:" & " " & S & "<br><br>" & _
"Please research this and let us know of your findings. Also, please contact the insured to discuss the situation and apologize. " & _
"For any further questions and resolution, you may reach the client at" & " " & PN & "<br><br>" & _
"</body>" & Signature
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
LetsContinue:
Application.DisplayAlerts = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
Thank you for your help!!