Ниже я использую данные для отправки информации по электронной почте. Вы должны будете изменить его в соответствии с вашими потребностями. Он использует функцию для форматирования HTML в теле письма с некоторой информацией. Это может быть немного излишним для того, что вам нужно, но оно должно указывать вам правильное направление.
Эта подпрограмма генерирует и отправляет электронное письмо:
Sub AppraisalReviewEmail()
Dim OutlookApp As Object, MItem As Object
Dim clsDate As Range, CustName As Range, PreSign As Range
Dim strBody As String, CindyAppraisalEmail As String, hyperlink As String, currDir As String, Target As String, lNum As String
Set clsDate = GeneralInfo.Range("genCloseDate")
Set PreSign = SheetData.Range("Pre_Sign_Date")
Set CustName = LoanData.Range("CustName1")
Set OutlookApp = CreateObject("Outlook.Application")
Set MItem = OutlookApp.CreateItem(0)
lNum = GeneralInfo.Range("genLoanNumber")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
AppraisalEmail = redacted for public viewing
currDir = MLAChecklist.path
hyperlink = "<a href=""" & Replace(currDir, " ", "%20") & """>" & currDir & "</a>"
Dim Subj As String, EmailAddr As String
With MItem
.To = AppraisalEmail
.Subject = UCase("Appraisal Review" & " - " & CustName & " - " & lNum & " - " & "Closing Date " & clsDate)
.Display
.htmlbody = getAppraisalCheckListHTML(hyperlink, getAppraisalCheckListItems) & .htmlbody
.Send
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Эти функции создают тело электронная почта с упорядоченным списком на основе элементов в указанной ячейке c:
Option Explicit
Function getAppraisalCheckListItems() As String
getAppraisalCheckListItems = "<li>" & Replace(SheetData.Range("Notes_for_Appraisal_Review").value, ",", "</li>" & vbNewLine & "<li>") & "</li>"
End Function
Function getAppraisalCheckListHTML(HyperlinkTag As String, CheckListItems As String) As String
Const Delimiter As String = vbNewLine
Dim list As Object
Set list = CreateObject("System.Collections.ArrayList")
Dim empName As String
empName = "Roger Rabbit"
If Len(SheetData.Range("Notes_for_Appraisal_Review")) = 0 Then
With list
.Add "<html>"
.Add "<body style=font-size:11pt;font-family:Calibri>"
.Add "Hello " & empName & ","
.Add "<p>Please complete the appraisal review for the following file:"
.Add "  "
.Add HyperlinkTag
.Add "<br><br>"
.Add "Thank You,"
.Add "</p>"
.Add "</body>"
.Add "</html>"
End With
Else
With list
.Add "<html>"
.Add "<body style=font-size:11pt;font-family:Calibri>"
.Add "Hello " & empName & ","
.Add "<p>Please complete the appraisal review for the following file:"
.Add "  "
.Add HyperlinkTag
.Add "<br><br>"
.Add "Items to make note of in the file."
.Add "<ol>"
.Add Trim(CheckListItems)
.Add "</ol>"
.Add "<br>"
.Add "Thank You,"
.Add "</p>"
.Add "</body>"
.Add "</html>"
End With
End If
getAppraisalCheckListHTML = Join(list.ToArray, Delimiter)
End Function