Excel VBA Outlook 电子邮件无法发送

问题描述 投票:0回答:1

我打开一个 UserForm VidEmailForm,它获取变量 ccPeeps、VidEmailSubject 和 VidEmailLink。这可以正常工作并且在 .Display 上看起来正确。 但是,当我点击“在 .Display 上发送”时,它不会发送。我尝试了 .Save ,它确实将其保存到我的草稿文件夹中,但是当我尝试发送该文件夹时,出现错误。我使用完全相同的代码发送默认电子邮件,效果很好。唯一的区别是身体。

Sub EmailforVids()
    ccPeeps = ""
    VidEmailForm.Show
    Dim EmailApp2 As Object, EmailItem2 As Object
    Dim Signature As String, xMailBody As String
    Set EmailApp2 = CreateObject("Outlook.application")
    Set EmailItem2 = EmailApp2.CreateItem(0)
    With EmailItem2
        .Display
    End With
    username = Environ$("USERNAME")
    Signature = GetSignature("DART")
    currentDate = Format(Now, "yyyymmdd")
    If Time < TimeValue("12:00:00") Then
        xMailBody = "Good Morning"
    ElseIf Time > TimeValue("12:00:00") And Time < TimeValue("17:00:00") Then
        xMailBody = "Good Afternoon"
    Else
        xMailBody = "Good Evening"
    End If 
    With EmailItem2
        .To = "(redacted)"
        .cc = ccPeeps
        .Subject = VidEmailSubject
        .HTMLbody = "<BODY style=font-size:12pt;font-family:Aptos>" & xMailBody & ",<br><br>" & "<a href =" & VidEmailLink & ">" & VidEmailSubject & "</a>" & "<br><br>" & _
        "Attached Review Players if needed for .cva files:<br><a href=" & """" & "https://redacted.sharepoint.com/:u:/s/tccapps/EbkNE4bZpbJFp2TLvs4cI7cBm1FqQ8WhiuR5191aGXydYA?e=mrKvYs" & """" & ">x64 Player</a>" & _
        "<br><a href=" & """" & "https://redacted.sharepoint.com/:u:/s/tccapps/EUKwdQSAtkJDv7tAMn1jvcgB891TeE74yiUfRM4exVReRw?e=wplpxf" & """" & ">win32 Player</a>" & _
        "<BR><BR>" & Signature
        .Display
        .Send
    End With
    Set EmailItem2 = Nothing
    Set EmailApp2 = Nothing
End Sub
excel vba email outlook
1个回答
0
投票

新 Outlook 不支持 VBA。

© www.soinside.com 2019 - 2024. All rights reserved.