我正在尝试将Outlook集成到VBA中。所以我按下按钮点击了一个示例代码,如下所示。
Private Sub CommandButton1_Click()
On Error GoTo ErrHandler
Dim objOL As New Outlook.Application
Dim objML As Outlook.MailItem
Set objML = objOL.CreateItem(olMailItem)
With objML
.to = "email@email.com"
.Subject = "This is a test message from Sandeep Thomas via VBA"
.Body = "Hi there"
.Send
End With
Set objOL = Nothing: objML = Nothing
Done:
Exit Sub
ErrHandler:
MsgBox "Error " + Err.Description
End Sub
但即使在邮件到达收件箱后,我仍然收到此消息“项目已被移动或删除”。我没有得到我做错了。
答案 0 :(得分:2)
试试这个:
Set objOL = Nothing: Set objML = Nothing