【发布时间】:2017-06-30 22:50:51
【问题描述】:
我有以下 VBA 代码来发送电子邮件:
Sub First_Email()
If ExitAll = False Then
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.HTMLbody
With OMail
.To = "test@test.de"
.Subject = "First E-Mail"
.HTMLbody = "<p> Once I click on the send button for this E-Mail I want that the E-Mail in the code below is sent as well.</p>"
End With
Set OMail = Nothing
Set OApp = Nothing
Else
End If
End Sub
此代码使用上述电子邮件打开 Outlook。由于用户在发送电子邮件之前仍有机会修改电子邮件,因此代码不会自动发送电子邮件。
一旦用户点击发送按钮,电子邮件就会被发送。现在,我想实现一旦用户单击第一封电子邮件的发送按钮,下面的电子邮件也会自动发送:
Sub Second_Email()
If ExitAll = False Then
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.HTMLbody
With OMail
.To = "test@test.de"
.Subject = "Second E-Mail"
.HTMLbody = "<p> Once I click on the send button for the first E-Mail I want that this E-Mail is sent as well.</p>"
.send
End With
Set OMail = Nothing
Set OApp = Nothing
Else
End If
End Sub
与第一封电子邮件相比,用户没有机会在第二封电子邮件发送之前对其进行修改。一旦用户单击第一封电子邮件的发送按钮,它应该立即发送。
您知道如何实现在用户点击第一封电子邮件中的发送按钮后自动发送第二封电子邮件吗?
【问题讨论】: