Reputation: 4759
I'm trying to integrate Outlook in VBA. So I did a sample code in a button click as follows.
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 protected]"
.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
But Im keep getting this message "The Item has been moved or deleted" even after the mail reaches the inbox. I didnt get what I did wrong.
Upvotes: 1
Views: 67