Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook add-in error: "The item has been moved or deleted" URGENT

Posted on 2004-10-25
20
Medium Priority
?
4,677 Views
Last Modified: 2013-01-18
My problem is to work with more than one instance of e-mail (MailItem).
When I try to send a mail item the send method works fine, but when I open two or more e-mails, send one and then send other, the e-mail object (MailItem) doesn't have the properties anymore returning the error message: "The item has been moved or deleted".

When the e-mail is sent, the e-mail object (MailItem) loses all its properties.

{Please do not post emails/websites in signature in questions - ee_ai_construct, cs admin}
 
0
Comment
Question by:caiodop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 2
  • +2
20 Comments
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406451
What version of outlook ?

Is your outlook fully updated ?

Check to see if you have word as the default email editor by going to tools -> options -> mail format
if you have it ,uncheck that option and use outlook as the email editor and see if that would solve your issue.

0
 

Author Comment

by:caiodop
ID: 12406497
Version: Outlook 11 (2003) - fully updated with SP1

I'm not using word editor.
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406533
caiodop,

without that add-in , are you able to send multiple emails fine.

have you tried to remove that add-in and add it back to see if that would help

Is this the first time you are working on this add-in or it has worked before fine
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:caiodop
ID: 12406588
I built it many times...

See if is there a problem with the code:

--CODE BEGIN--
(...)
'----------NEW INSPECTOR
Private Sub m_olInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles m_olInspectors.NewInspector
        Try
            m_olInspector = CType(Inspector, Outlook.InspectorClass)
            If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
                'Must cast to MailItemClass due to "ambiguous name" problem
                m_olMailItem = CType(Inspector.CurrentItem, Outlook.MailItemClass)
            ElseIf TypeOf Inspector.CurrentItem Is Outlook.PostItem Then
                m_olPostItem = CType(Inspector.CurrentItem, Outlook.PostItem)
            'ANOTHERS TYPE VERIFICATIONS
            (...)
            End If
        Catch ex As Exception
            MsgBox(ex.Message & Chr(13) & "Please, try again." & Chr(13) & Chr(13) & "If this problem persists, contact your system administrator. Code: 0013", MsgBoxStyle.Exclamation, "Outlook")
        End Try
    End Sub

'----------MAIL OPEN
    Private Sub m_olMailItem_Open(ByRef Cancel As Boolean) Handles m_olMailItem.Open
        Try
            CBBSaveSendOnOff(m_olMailItem, True, True) 'Just make buttons
        Catch ex As Exception
            MsgBox(ex.Message & Chr(13) & _
            "Please, try again." & Chr(13) & Chr(13) & "If this problem persists, contact your system administrator. Code: 0017", MsgBoxStyle.Exclamation, "Outlook")
        End Try
    End Sub

--CODE END--

Up to here I have the item opened. When the user clicks on my button...:

--CODE BEGIN--
'----------CLICK ON THE CUSTOM SEND BUTTON
    Private Sub CBBSendEmail_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles CBBSendEmail.Click
        Try
            If Not (m_olMailItem Is Nothing) Then
                BTNSend = True 'JUST FOR A FUTURE VERIFICATION
                m_olMailItem.Send()
            End If
        Catch ex As Exception
            MsgBox(ex.Message & Chr(13) & _
            "Please, try again." & Chr(13) & Chr(13) & "If this problem persists, contact your system administrator. Code: 0024", MsgBoxStyle.Exclamation, "Outlook")
        End Try
    End Sub
--CODE END--

This m_olMailItem has all the properties of the e-mail. When an e-mail is sent, it loses its properties. So when is opened more than one e-mail and one of them is sent, the other one doesn't have the necessary properties to send the e-mail.

Did you understand my problem?

Caio
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406650
caiodop,

Sorry , I am not good at this.. I shall try to get help for you here.. Hang on

SR
0
 

Author Comment

by:caiodop
ID: 12406696
OK SR, I wait for your help!
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406720
caiodop,

Have asked the PE for this TA to contact some experts who are good at coding in outlook. Hope they would be here soon

SR
0
 

Author Comment

by:caiodop
ID: 12406751
OK SR...

I'll be trying a solution... It's late here (11pm at office!).... but I need to solve it!

Thanks... I'm waiting for any help!

Caio
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406756
11 pm ? which location are you in .. somewhere in canada or atlantic ocean..
0
 

Author Comment

by:caiodop
ID: 12406782
Brazil... was this the best channel to place my question? I post another at Programming > Windows Application, but without answers until now...
0
 
LVL 49

Expert Comment

by:sunray_2003
ID: 12406794
Ok.  This is the perfect place to post this question..  Please wait till some other experts well versed in coding come here..
0
 

Author Comment

by:caiodop
ID: 12406881
I'll go home now... sleep to wake up early tomorrow and solve this problem... if someone help me, please, post here or send me an email {2 adresses removed - ee_ai_construct, cs admin (see http:help.jsp#hi99 for details)}

I'll be back in about 8 hours...

I appreciate any help.

Caio
0
 
LVL 13

Expert Comment

by:stefri
ID: 12408274
caiodop,
I do not know the language you are using even if it looks like VB but:
how is declared m_olMailItem? Seems to be global variable which is initialized in m_olInspectors_NewInspector.
If you have more than one item opened, it will be replaced by the new value?
The custom button belongs to the mail you are sending? Cant you get a handle on the mail item itself as the sub does not reference it.
Stefri


0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12408754
Hi All,
(caiodop, I'm not one of the experts called in, but rather a passer by with a comment)
    I also am not familiar with the language (am guessing it is Java or a similar scripting language), but what about setting a hard limit on how many emails you can work with? Set up multiple MailItem Objects and in the send sequence each one is cleared, so when you try to open a new one it looks to si if one of the Objects is empty first and if so assigns the MailItem to that object, if not pops up a message to the user that they have reached the limit of open emails.
    I realize this is rather limiting, to hard code a limit into your app for the number of open MailItems. Like I said I am not one of the coding experts.

Sam
0
 
LVL 1

Accepted Solution

by:
ttmac earned 2000 total points
ID: 12408765
caiodop,

It sounds as if the mail item you are trying to send is no longer an active mailitem.  This would be true if your user opens an email and returns to the outlook window and opens a second email.  After the send event has taken place, windows returns to the previous window that was active, and in this case it returns to the Outlook Window.

In order to be able to send the first email you will firstly have to make it current.  In the windows environment this would be by clicking on the mailitem button on the task bar or by ALT-Tabbing.

To implement this in code, you will need to use the Active Inspector method.  This returns the topmost Inspector object on the desktop. If no inspector is active, returns Nothing. Use this method to access the Inspector object that the user is most likely to be viewing.

A sample of its use in the VBA environment (from the VBA help) is: -

Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
MsgBox "The active item is " & myInspector.CurrentItem.Subject

Tom.

0
 

Author Comment

by:caiodop
ID: 12410888
I think that everybody understood the problem.

About Sam's idea, I had been thought before and it would work fine, but I want to try something else to do not limit the users or fill a large memory space, I'm going to make it just on a B plan :)

Using Stefri's idea and Tom's VBA code it works fine, but I'm building using VB.NET in Visual Studio .NET 2003, so I need something to integrate the VB.NET to the VBA code. Maybe VSTO?

I have two objects that are not working fine:
1) The inspetor: the inspector object just get the first e-mail
2) The MailItem: after sending, it loses the properties, so when I try to send another I get the error message: "The item has been moved or deleted".

Any ideas about what is the best thing to do?

Thanks for the help... in our area we really need a strong and cooperative community to work together!
Caio
0
 
LVL 1

Expert Comment

by:ttmac
ID: 12412073
caiodop,

When you send the mail item, is the instance of the inspector remaining open even though the mail item has been sent?

If this is the case you might appear to have an inspector set as the current inspector eventhough it does not contain a mail item.  

I have no experience of VB.Net  so I cannot offer you any advice in that regard, however if you are making reference to the outlook object in your references and you are able to create and manipulate Outlook objects there should be no reason why you cannot integrate the VBA example above into your application.  VBA is simply a cut down version of VB.  

A possible alternative that you might consider is to loop through all the inspectors that are open and test if they possess the properties that you require, then set one of them as the active or current inspector.

Tom.
0
 

Author Comment

by:caiodop
ID: 12413640
Tom,

I've tryed many times to get the current item (Inspector), but I anything worked until now...

I have an idea... I'm going to try and tell you if it worked.

Caio
0
 

Author Comment

by:caiodop
ID: 12447343
I did it and it is working well using Tom's idea...!

I'd like to thank everyone here!

Below is the finally working code:

--CODE BEGIN--

    Private Sub CBBSendEmail_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles CBBSendEmail.Click
        Try
            m_olInspector = CType(m_olApp.ActiveInspector, Outlook.InspectorClass)
            getItem(m_olInspector)
            If Not (m_olMailItem Is Nothing) Then
                BTNSend = True
                m_olMailItem.Send()
                m_olInspector = CType(m_olApp.ActiveInspector, Outlook.InspectorClass)
                getItem(m_olInspector)
            End If
            'Wilson: 1.0.1.41 - end
        Catch ex As Exception
            MsgBox(ex.Message & Chr(13) & _
            "Please, try again." & Chr(13) & Chr(13) & "If this problem persists, contact your system administrator. Code: 0024", MsgBoxStyle.Exclamation, "Outlook")
        End Try
    End Sub

    Private Sub getItem(ByVal inspector As Outlook.InspectorClass)
        Try
            If TypeOf inspector.CurrentItem Is Outlook.MailItem Then
                'Must cast to MailItemClass due to "ambiguous name" problem
                m_olMailItem = CType(inspector.CurrentItem, Outlook.MailItemClass)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.PostItem Then
                m_olPostItem = CType(inspector.CurrentItem, Outlook.PostItem)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.AppointmentItem Then
                m_olAppointmentItem = CType(inspector.CurrentItem, Outlook.AppointmentItem)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.ContactItem Then
                m_olContactItem = CType(inspector.CurrentItem, Outlook.ContactItem)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.DistListItem Then
                m_olDistListItem = CType(inspector.CurrentItem, Outlook.DistListItem)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.JournalItem Then
                m_olJournalItem = CType(inspector.CurrentItem, Outlook.JournalItem)
            ElseIf TypeOf inspector.CurrentItem Is Outlook.TaskItem Then
                m_olTaskItem = CType(inspector.CurrentItem, Outlook.TaskItem)
            End If
        Catch ex As Exception
            'This try block is just to threat if the last mail is closed and there is no Inspector open
        End Try
    End Sub

--CODE END--

Best regards,

Caio Pereira
{Please do not post emails/websites in signature in questions - ee_ai_construct, cs admin}
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question