您可以使用宏發送電子郵件,然後用短鍵觸發它,手動或添加一個調用它的按鈕。要創建一個,請按Alt - F11打開編輯器。單擊插入 - >模塊,並添加以下代碼:
Sub SendEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Dear parent," & vbNewLine & vbNewLine & _
"This is your child's report:" & vbNewLine
Cells(1, 4).Value & " :" & Cells(2, 4).Value & vbNewLine
Cells(1, 6).Value & " :" & Cells(2, 6).Value & vbNewLine
Cells(1, 7).Value & " :" & Cells(2, 7).Value & vbNewLine
Cells(1, 8).Value & " :" & Cells(2, 8).Value & vbNewLine
Cells(1, 9).Value & " :" & Cells(2, 9).Value
On Error Resume Next
With OutMail
.To = Cells(1,12).Value
.CC = ""
.BCC = ""
.Subject = "Student Report"
.Body = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
不管你把strbody
將是電子郵件的正文。您可以使用Cells(columnnumber, rownumber).Value
函數使用單元格的值。您可以查看this support page以瞭解如何使用按鈕,或者在this page上手動或使用快捷鍵運行。通過首先發送給自己來仔細檢查,然後根據自己的口味進行編輯。