Re: MailItem.Close()

Status
Not open for further replies.
U

U3RlRmV0Uw

Hello,

What we have done at work is to create a thread

In the Inspector Clos event :

If RemoveItemAfterClose Then

Dim TS As New System.Threading.ThreadStart(AddressOf

WrapperMailItem.Delete)

Dim t As System.Threading.Thread = New System.Threading.Thread(TS)

Try

t.Start()

Catch ex As Exception

MsgBox(ex.ToString)

End Try

End If

Works like a charm
wrote:


> Close is synchronous but you can't delete the item in that event handler
> without errors in some versions of Outlook.

> Outlook also caches items so you have to wait for it to be released.

> I usually use a timer to do the deletions and set up an array of EntryID's
> of items to delete. When the timer fires I sweep the array clean.

> >

>

> "Alan Moseley" <AlanMoseley> wrote in message
> news:FC96CDD9-F303-45BC-9B94-4271DC8B3969@microsoft.com...
> >I do not know for certain if it is synchronous or not, but I suspect that
> >it
> > is. Can you post the relevant section of your code. I suspect that you
> > are
> > under certain circumstances not setting the mailitem's object variable
> > back
> > to nothing before deleting the folder. Also, calling the mailitem's
> > delete
> > method invokes the inspector to close anyway, so you probably do not need
> > to
> > call it separately.
> > > > Alan Moseley IT Consultancy
> > http://www.amitc.co.uk
> > If I have solved your problem, please click Yes below. Thanks.


>
 
K

Ken Slovak - [MVP - Outlook]

Just make sure you do not access the Outlook object model on that thread or

if you do that you first marshal the thread to the main thread in your code.

Otherwise you not only crash or hang Outlook but also break any other addin

that's running.

If you cannot meet those conditions then your solution will cause problems,

not fix them.

"SteFetS" <SteFetS> wrote in message

news:46C6E821-1969-4DFD-9649-5AFBA9B689A3@microsoft.com...
> Hello,

> What we have done at work is to create a thread

> In the Inspector Clos event :

> If RemoveItemAfterClose Then
> Dim TS As New System.Threading.ThreadStart(AddressOf
> WrapperMailItem.Delete)
> Dim t As System.Threading.Thread = New
> System.Threading.Thread(TS)
> Try
> t.Start()
> Catch ex As Exception
> MsgBox(ex.ToString)
> End Try
> End If

> Works like a charm
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
U Outbox Message Stuck after reading some MailItem Properties with VBA Outlook VBA and Custom Forms 1
oliv- Best practice for catching mailitem.events Outlook VBA and Custom Forms 0
oliv- How to select an mailitem in explorer with "show as conversation" Outlook VBA and Custom Forms 8
JorgeDario How to capture and save the text, when responding a MailItem? Outlook VBA and Custom Forms 3
JorgeDario how to check a MailItem has a digital signature (SMIME) with vba? Outlook VBA and Custom Forms 1
JorgeDario ¿What property of mailitem can be used like primary key? Outlook VBA and Custom Forms 6
S Outlook VBA rule script to process both MailItem and MeetingItem Using Outlook 0
B right click outlook objects in OL2010 acts on current inbox mailitem Using Outlook 6
C MailItem Find method doesn't work Using Outlook 0
C MailItem.SaveAs not working Outlook VBA and Custom Forms 10
G RE:The signature is also inserted if you touch the MailItem. Outlook VBA and Custom Forms 1
B Add signature to MailItem Outlook VBA and Custom Forms 3
C How can I create a new MailItem inside a user folder? Outlook VBA and Custom Forms 4
S Create a new Outlook MailItem in an Outlook folder(not a draft) Outlook VBA and Custom Forms 2
A How to get OOM MailItem Raw data Outlook VBA and Custom Forms 2
S Saved Property of MailItem is copied Outlook VBA and Custom Forms 1
S MailItem Find Method question Outlook VBA and Custom Forms 6
N Getting the attachments in MailItem Outlook VBA and Custom Forms 1
T How to get MailItem.Body without security warning in Outlook 2010 Outlook VBA and Custom Forms 2
S ->[O2007] Parsing each line of a MailItem HTMLBody? Outlook VBA and Custom Forms 2
T How to get Inspector or MailItem from wordEditor Outlook VBA and Custom Forms 6
A Select the position of an attached file in a HTML mailitem Outlook VBA and Custom Forms 1
M MailItem object has no property for when a reply was sent Outlook VBA and Custom Forms 3
B Insert information to MailItem Outlook VBA and Custom Forms 1
E Properties added to MailItem in ItemSend event visible to recipien Outlook VBA and Custom Forms 1
V Setting HTMLBody of new mailItem Outlook VBA and Custom Forms 1
V How to find mailitem in the inspector is a brand new one Outlook VBA and Custom Forms 2
M Activate "Add digital signature to this massage" on a MailItem? Outlook VBA and Custom Forms 1
K importing EML in MailItem Outlook VBA and Custom Forms 1
A mailitem Send issue Outlook VBA and Custom Forms 5
M Get email address from MailItem.To? Outlook VBA and Custom Forms 6
S UserProperties of MailItem object. Outlook VBA and Custom Forms 3
R How to capture a Mailitem Event Outlook VBA and Custom Forms 3
S get current position in message body of mailitem Outlook VBA and Custom Forms 8
S How to get RFC822 format message from the MailItem object. Outlook VBA and Custom Forms 4
J Toolbar button to process current mailitem Outlook VBA and Custom Forms 1
D MailItem from an RSS feed Outlook VBA and Custom Forms 2
J Outlook 2007 crashed when pushing send on a displayed mailitem Outlook VBA and Custom Forms 1
N Memory with MailItem.Send Outlook VBA and Custom Forms 1
P Adding a button in a mailitem Outlook VBA and Custom Forms 1
S Reading mailitem after mail is send give runtime error. Outlook VBA and Custom Forms 1
D Max. length of MSO MailItem.EntryID Outlook VBA and Custom Forms 6
R MailItem.Display() error Outlook VBA and Custom Forms 1
R Clone mailitem Outlook VBA and Custom Forms 5
R MailItem Outlook VBA and Custom Forms 2
D Length of the MailItem.EntryID Outlook VBA and Custom Forms 2
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 1
M What is the recommendet way to read/write a user defined Field (Named Property) in the MailItem Obje Outlook VBA and Custom Forms 5

Similar threads

Top