如何在VBA中结束邮件?

时间:2016-05-24 11:03:15

标签: excel vba excel-vba email

这让我很疯狂,我确信这个问题已经解决了很多次,但是我无法在这个论坛或Google上找到它。所以我为此制作一个主题道歉。

我不知道如何结束正文。

非常感谢。

    With OutMail
        .To = "" ' Either an email address or a cell value that contains an email address: ActiveSheet.Range("B11").Value
        .CC = ""
        .BCC = ""
        .Body = "Geachte heer, mevrouw," & vbNewLine & _
        " " & vbNewLine & _
        "De volgende kasbankopdrachten staan klaar in Kasweb onder rekeningnummer........ Ik verzoek u ze te valideren." & vbNewLine & _
        "Bijgaand ontvangt u het boedeloverzicht, tevens treft u hieronder de berekening van het nog te innen bewindvoerdersalaris en onkosten." & vbNewLine & _
         ActiveSheet.Range("C4").Value & Space(3) & ActiveSheet.Range("C3").Value & Space(10) & ActiveSheet.Range("C3").Value & Space(20) & ActiveSheet.Range("C27").Value & Space(5) & ActiveSheet.Range("B27").Value & vbNewLine & _
         ActiveSheet.Range("C4").Value & Space(3) & ActiveSheet.Range("C3").Value & Space(10) & ActiveSheet.Range("B2").Value & Space(15) & ActiveSheet.Range("C26").Value & Space(5) & ActiveSheet.Range("B26").Value & vbNewLine & _
         " " & vbNewLine & _
         "Salaris volgens vonnis (incl. 21% BTW)" & Space(14) & ThisWorkbook.Worksheets("Salaris").Cells("42, P").Value & vbNewLine & _
         ""
        .Subject = ActiveSheet.Range("C4").Value & Space(3) & ActiveSheet.Range("C5").Value & Space(3) & ActiveSheet.Range("C3").Value
        .Display  ' Change this to Send if you want to automatically send it without preview
        .Attachments.Add PdfFile  ' Delete this line if you don't want the attachment
    End With
On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

1 个答案:

答案 0 :(得分:9)

Cells("42, P").Value

应该是

Cells("42", "P").Value

您收到该错误是因为您向Cells()方法提供了无效参数