Outlook 未从 Excel 发送提醒电子邮件

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

我正在尝试使用 Excel 和 VBA 发送提醒电子邮件。我使用的是 Excel 2007 和 Outlook 2007。当我运行它时,在 Outlook 中显示消息,但电子邮件尚未发送。

这是代码

Sub send_mail()
Dim OutApp As Object
Dim outmail As Object
Dim mail_list As Range
Dim cell As Range

Application.ScreenUpdating = False

Set OutApp = CreateObject("Outlook.Application")
On Error GoTo error_exit

Set mail_list = Range(Range("D3"), Range("D3").End(xlDown))

For Each cell In mail_list
    Set outmail = OutApp.createitem(0)
    On Error Resume Next
    With outmail
        .to = cell.Value
        .Subject = "Reminder"
        .body = "Postovana " & Cells(cell.Row, "C").Value & "," & vbNewLine & vbNewLine & _
        "Ovo je generisana poruka. Molim Vas da se javite na pregled." & vbNewLine & vbNewLine & _
        "Srdacan pozdrav" & vbNewLine & _
        "dr Sandra Kljajic"
        .display
    End With
    On Error GoTo 0
    Set outmail = Nothing
    
Next cell

error_exit:
Set OutApp = Nothing

Application.ScreenUpdating = True

End Sub

有人可以帮助我吗?

excel vba reminders
1个回答
0
投票

该代码目前仅要求显示草稿电子邮件。如果您将 With 语句中的 .display 替换为 .send,电子邮件将自动发送。

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