Outlook Error 'The operation cannot be performed because the object has been deleted.'

R

Rolf

Hi all,

I am sending a mail through Excel, we now have Office 2003. On Office
2k it was still working for ages. I am having the mail in a VBA class.
The part below throws the error 'The operation cannot be performed
because the object has been deleted.' when i show the MailItem before
sending AND having an file attached. If i am sending the mail with or
without attachment straight without displaying first, it works perfekt.
Has anybody an idea?

Intersting, if i remove and add the attachment again when displaying
the mail, it works. The problem causes the attachment. (The file
attached file is small, just a single s/s with one page and a few
lines.) Ihave no clue how i can make it run again with displaying the
msg first.

Thx and Cheers
Rolf

'Simpyfied sending procedure in clsMail
Public Sub SendMail()

Dim objOutlook As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim objRecipient As Object

Dim i As Integer
Dim iCountWrongRecipients As Integer

On Error GoTo Err_MailTo_Immediat

Set objOutlook = Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
'Check if they exist, if not, underline them red
If IsArray(MailTo) Then
For i = LBound(vaMailTo) To UBound(MailTo)
Set objRecipient =
objMailItem.Recipients.Add(MailTo(i))
objRecipient.Type = 1 'olTo
If Not objRecipient.Resolve Then
iCountWrongRecipients = iCountWrongRecipients + 1
End If
Next
End If

'THE PART WITH THE ATTACHMENT RESULTS THE ERROR!
'If optional variable has a attachement
If Not IsEmpty(Attachements) And IsArray(Attachements) Then
For i = LBound(Attachements) To UBound(Attachements)
.Attachments.Add Attachements(i)
Next
End If

.Subject = Header
.BodyFormat = 1 'olFormatPlain
.Body = Message

'.Display
.Importance = Importance 'bytImportance 'olImportanceHigh = 2
'show message on screen for checking/adding/correcting
If iCountWrongRecipients > 0 Then
MsgBox iCountWrongRecipients & " recipeints could not be
resolved!", vbExclamation
bDisplay = True 'Errors, so display anyway
End If
'Display msg b4 send
If bDisplay And iCountWrongRecipients > 0 Then
Call LogData(iCountWrongRecipients & " recipeints could not
be resolved!")
.Display
ElseIf bDisplay Then
.Display
Else
.Send
End If
End With
Set objOutlook = Nothing
Set objMailItem = Nothing
ReturnID = 0
Exit Sub

Err_MailTo_Immediat:
lReturnID = Err.Number
sReturnMsg = Err.Description
End Sub
 
R

Rolf

The problem is solved. The causing comonent was an Add-In in Outlook.
Tools-Options...-Other-Advanced Options...-Add-In Manager... Removing
it and everything worked fine. ...or fix the add-in ;-)
 
Joined
Jun 8, 2006
Messages
1
Reaction score
0
OUTLOOK ERROR - Object deleted

Hi,

I am getting the error while trying to send outlook mail using microsoft excel.
The error is that "The operation cannot be performed because the object has been deleted."

Do somebody have resolution to this problem.

Thanx,

SIDHU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top