Hello,
I've been able to figure out that there can only be one set of parentheses in the .HTMLBody portion of the code. However, I can't seem to figure out how to call forth the values from each range and have them populate within the email. To illustrate the type mismatch error that I'm receiving I purposely put everything in parentheses in the .HTMLBody section. Then, under the .subject section, I tried to call forth the applicable value using, & Answer13(Counter, 1) = ProjectNumber, which gave me the type mismatch error. My goal is to be able to have the email populate with the values from the ranges in the specific locations of the subject and body of the email. I'm not sure if this is possible. Someone, please assist. Thank you
Sub EmailType1Send()
Dim olApp As Outlook.Application
Dim olemail As Outlook.MailItem
Dim EmailType() As Variant
Dim ProjectNumber() As Variant
Dim ProjectName() As Variant
Dim EndDate() As Variant
Dim ActualBalanceRemaining() As Variant
Dim EncumbranceBalanceRemaining() As Variant
Dim Dimension13 As Long
Dim Answer13() As Variant
Dim Counter As Long
EmailType = Range("V2", Range("V2").End(xlDown))
ProjectNumber = Range("A2", Range("A2").End(xlDown))
ProjectName = Range("C2", Range("C2").End(xlDown))
EndDate = Range("F2", Range("F2").End(xlDown))
ActualBalanceRemaining = Range("O2", Range("O2").End(xlDown))
EncumbranceBalanceRemaining = Range("L2", Range("L2").End(xlDown))
Dimension13 = UBound(EmailType, 1)
ReDim Answer13(1 To Dimension13, 1 To 1)
For Counter = 1 To Dimension13
If EmailType(Counter, 1) = "Type 1" Then
Set olApp = New Outlook.Application
Set olemail = olApp.CreateItem(0)
With olemail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Good Morning,<br> <br> This email is following up on your project entitled, Answer13(Counter, 1) = ProjectName scheduled to end .Answer13(Counter, 1) = EndDate. Currently this project has an actual balance remaining of .Answer13(Counter, 1) = ActualBalanceRemaining and has .Answer13(Counter, 1) = EncumbranceBalanceRemaining encumbrances remaining. At this time it looks like there's a strong possibility for closing out this project. Please let me know how you'd like to proceed with the closeout of this project and let me know if you have any questions. Thanks and have a nice day. <br> <br>" & .HTMLBody
.To = ""
.Subject = "Strong Closeout Possibility:" & Answer13(Counter, 1) = ProjectNumber
End With
End If
Stop
Next Counter
End Sub
Bookmarks