代码之家  ›  专栏  ›  技术社区  ›  Adamlh77

如何将外部附件添加到通过Excel VBA发送的电子邮件中?

  •  0
  • Adamlh77  · 技术社区  · 7 年前

    我有一个Excel中的VBA,用户在那里填写表单,然后单击按钮将其发送到团队电子邮件地址。我希望能够有一个框出现在发送电子邮件之前,允许用户在发送之前附加外部附件到电子邮件。

    Private Sub CommandButton1_Click()
        Dim user
        Dim bookName As String
        Dim mailAns
    
        user = Environ("UserName")
        bookName = "General Order Form 2018" + " " + Format(CStr(Date), "dd-mm-yyyy") + "  " + user
    
        If MsgBox("Do you wish to send this General Order Form to Print Services?", vbYesNo) = vbNo Then
        End If
    
        With Sheets("Order Form 2019")
            If .CheckBox1 = True Then
    
                ThisWorkbook.SendMail Recipients:=Array("Print.Services@nationwide.co.uk"), Subject:="New Print Request", Returnreceipt:=True
                MsgBox "The Print Order Form has been sent to the Print Services Team, you will be contacted within 1 working day"
                ThisWorkbook.Close
                Exit Sub
    
            Else
                MsgBox "You have not completed the Declaration. Please accept the statements by clicking the checkbox"
    
            End If
        End With
    
    End Sub
    
    0 回复  |  直到 7 年前