提前感谢您的帮助。我有以下代码,单击该代码会创建一封电子邮件,插入正文和客户电子邮件地址并附上发票副本。我有两个问题,一个是可以更改附件的名称,目前它只是 invoiceF.pdf 可以用它作为交付的参考。其次,是否可以捕获发送邮件的结果?我知道如果电子邮件没有发送,只是关闭,访问会显示一个信息框,上面写着“发送对象操作已取消”,我想捕捉“成功发送”确认并将今天的日期添加到一个框 [invoiceemailed]。感谢任何人提前提供帮助:)
Private Sub emailinvoiceF_Click()
On Error GoTo Err_emailinvoiceF_Click
If MsgBox("Email the invoice?", vbYesNo) = vbYes Then
Dim strMessage
strMessage = "Dear " & First & " " & Last & "," _
& vbCrLf & vbCrLf & "Thank you for your order: (" & DeliveryID & "), please find attached invoice." _
& vbCrLf & vbCrLf & "If you require any further information please do not hesitate to contact us." _
& vbCrLf & vbCrLf & "Kind Regards," _
& vbCrLf & vbCrLf & "SMI Hardwoods" _
& vbCrLf & vbCrLf & "Tel: 01206 396725" _
& vbCrLf & vbCrLf & "www.smi-hardwoods.com" _
Dim stDocName As String
stDocName = "InvoiceF"
DoCmd.SendObject acReport, stDocName, acFormatPDF, [E-mail address], , , "SMI Hardwoods Invoice Ref:" & DeliveryID & ".pdf", strMessage
End If
Exit_emailinvoiceF_Click:
Exit Sub
Err_emailinvoiceF_Click:
MsgBox Err.Description
Resume Exit_emailinvoiceF_Click
End Sub