A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Cache Mode Not allowing Sent Folder Update



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 30th 07, 11:30 PM posted to microsoft.public.outlook.program_vba
DG
external usenet poster
 
Posts: 31
Default Cache Mode Not allowing Sent Folder Update

--Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was just sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just sent, I
only get the last e-mail to enter the queue. If I remove Cache Mode, it works
like a champ, I get the e-mail just sent by the user. I have added delays,
but nothing works. Here's the code:

.......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to find the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder if I am
in Cache mode?
Ads
  #2  
Old May 1st 07, 12:47 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Cache Mode Not allowing Sent Folder Update

Use the Items.ItemAdd event on the Sent Items folder contents table rather
than wait for a newitem to appear in the folder.
Besides being extremely ineffcient, your code does not let the Windows
message pump run (which is used by the MAPI notification mechanism)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
news
--Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was just
sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just sent,
I
only get the last e-mail to enter the queue. If I remove Cache Mode, it
works
like a champ, I get the e-mail just sent by the user. I have added delays,
but nothing works. Here's the code:

......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to find the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder if I am
in Cache mode?



  #3  
Old May 1st 07, 07:32 AM posted to microsoft.public.outlook.program_vba
DG
external usenet poster
 
Posts: 31
Default Cache Mode Not allowing Sent Folder Update

Dmitry, that worked perfectly as you have been telling me for the past few
weeks. It just took me a while to "get it". I converted your original C code
to VB.net using some help out there. My only issue is how to convert "Item"
to Redemption.SafeMailItem:

Public objFolder As Outlook.MAPIFolder
Public WithEvents objFolderItems As Outlook.Items

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

'Used to watch over the Sent Items list
Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook._NameSpace = objOutlook.Session
objFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail)

objFolderItems = objFolder.Items
AddHandler objFolderItems.ItemAdd, AddressOf objFolderItemAdded
End Sub

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
'This line fails
sentItem.Item = Item
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''

SentItem.SaveAs........blah blah blah

End Sub

Thanks again Dmitry

"Dmitry Streblechenko" wrote:

Use the Items.ItemAdd event on the Sent Items folder contents table rather
than wait for a newitem to appear in the folder.
Besides being extremely ineffcient, your code does not let the Windows
message pump run (which is used by the MAPI notification mechanism)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
news
--Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was just
sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just sent,
I
only get the last e-mail to enter the queue. If I remove Cache Mode, it
works
like a champ, I get the e-mail just sent by the user. I have added delays,
but nothing works. Here's the code:

......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to find the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder if I am
in Cache mode?




  #4  
Old May 1st 07, 08:18 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Cache Mode Not allowing Sent Folder Update

Try something like the following:

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem
sentItem.Item = Item
MsgBox sentItem.SenderName


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
...
Dmitry, that worked perfectly as you have been telling me for the past few
weeks. It just took me a while to "get it". I converted your original C
code
to VB.net using some help out there. My only issue is how to convert
"Item"
to Redemption.SafeMailItem:

Public objFolder As Outlook.MAPIFolder
Public WithEvents objFolderItems As Outlook.Items

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

'Used to watch over the Sent Items list
Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook._NameSpace = objOutlook.Session
objFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail)

objFolderItems = objFolder.Items
AddHandler objFolderItems.ItemAdd, AddressOf objFolderItemAdded
End Sub

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
'This line fails
sentItem.Item = Item
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''

SentItem.SaveAs........blah blah blah

End Sub

Thanks again Dmitry

"Dmitry Streblechenko" wrote:

Use the Items.ItemAdd event on the Sent Items folder contents table
rather
than wait for a newitem to appear in the folder.
Besides being extremely ineffcient, your code does not let the Windows
message pump run (which is used by the MAPI notification mechanism)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
news
--Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was just
sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just
sent,
I
only get the last e-mail to enter the queue. If I remove Cache Mode, it
works
like a champ, I get the e-mail just sent by the user. I have added
delays,
but nothing works. Here's the code:

......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to find
the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder if I
am
in Cache mode?






  #5  
Old May 1st 07, 07:37 PM posted to microsoft.public.outlook.program_vba
DG
external usenet poster
 
Posts: 31
Default Cache Mode Not allowing Sent Folder Update

Yes, that works. What I have is a very interesting timing issue instead. What
happens is the e-mail is sent and my next step is to grab that Send Folder
safe e-mail and save it to the C:\.... drive. But I can't because the
objFolderItemAdded event does not occur fast enough. So what I am doing
instead is moving all steps into objFolderItemAdded which is kind of odd.
Does that makes sense? I just hate relying on the event function and moving
all control away from the main class I have written.


"Dmitry Streblechenko" wrote:

Try something like the following:

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem
sentItem.Item = Item
MsgBox sentItem.SenderName


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
...
Dmitry, that worked perfectly as you have been telling me for the past few
weeks. It just took me a while to "get it". I converted your original C
code
to VB.net using some help out there. My only issue is how to convert
"Item"
to Redemption.SafeMailItem:

Public objFolder As Outlook.MAPIFolder
Public WithEvents objFolderItems As Outlook.Items

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

'Used to watch over the Sent Items list
Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook._NameSpace = objOutlook.Session
objFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail)

objFolderItems = objFolder.Items
AddHandler objFolderItems.ItemAdd, AddressOf objFolderItemAdded
End Sub

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
'This line fails
sentItem.Item = Item
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''

SentItem.SaveAs........blah blah blah

End Sub

Thanks again Dmitry

"Dmitry Streblechenko" wrote:

Use the Items.ItemAdd event on the Sent Items folder contents table
rather
than wait for a newitem to appear in the folder.
Besides being extremely ineffcient, your code does not let the Windows
message pump run (which is used by the MAPI notification mechanism)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
news --Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was just
sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just
sent,
I
only get the last e-mail to enter the queue. If I remove Cache Mode, it
works
like a champ, I get the e-mail just sent by the user. I have added
delays,
but nothing works. Here's the code:

......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to find
the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder if I
am
in Cache mode?






  #6  
Old May 1st 07, 07:58 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Cache Mode Not allowing Sent Folder Update

I don't see anything wrong here...
If you are concerned that the event mightt not fire for whatever reason, you
can save the message as a file before sending it, then overwrite the file
when the event fires. This way you will at least have something if ItemAdd
is not fired.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
...
Yes, that works. What I have is a very interesting timing issue instead.
What
happens is the e-mail is sent and my next step is to grab that Send Folder
safe e-mail and save it to the C:\.... drive. But I can't because the
objFolderItemAdded event does not occur fast enough. So what I am doing
instead is moving all steps into objFolderItemAdded which is kind of odd.
Does that makes sense? I just hate relying on the event function and
moving
all control away from the main class I have written.


"Dmitry Streblechenko" wrote:

Try something like the following:

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem
sentItem.Item = Item
MsgBox sentItem.SenderName


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
...
Dmitry, that worked perfectly as you have been telling me for the past
few
weeks. It just took me a while to "get it". I converted your original C
code
to VB.net using some help out there. My only issue is how to convert
"Item"
to Redemption.SafeMailItem:

Public objFolder As Outlook.MAPIFolder
Public WithEvents objFolderItems As Outlook.Items

Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

'Used to watch over the Sent Items list
Dim objOutlook As Outlook._Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook._NameSpace = objOutlook.Session
objFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.ol FolderSentMail)

objFolderItems = objFolder.Items
AddHandler objFolderItems.ItemAdd, AddressOf
objFolderItemAdded
End Sub

Public Sub objFolderItemAdded(ByVal Item As Object)
Public sentItem As Redemption.SafeMailItem

MsgBox("Item was added!!!")
sentItem = New Redemption.SafeMailItem

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
'This line fails
sentItem.Item = Item
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''

SentItem.SaveAs........blah blah blah

End Sub

Thanks again Dmitry

"Dmitry Streblechenko" wrote:

Use the Items.ItemAdd event on the Sent Items folder contents table
rather
than wait for a newitem to appear in the folder.
Besides being extremely ineffcient, your code does not let the Windows
message pump run (which is used by the MAPI notification mechanism)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"DG" wrote in message
news --Outlook 2003 sp2
--VSTO 2005

My goal is to capture the e-mail in the Sent Items folder that was
just
sent
by the user. If Cache Mode is enabled, I never "get" the e-mail just
sent,
I
only get the last e-mail to enter the queue. If I remove Cache Mode,
it
works
like a champ, I get the e-mail just sent by the user. I have added
delays,
but nothing works. Here's the code:

......
Dim loopStartTime As Date = Date.Now
Dim numBeforeSent, numAfterSent As Integer

'objFolder is the Sent folder
numBeforeSent = objFolder.Items.Count

'_thisMail is MailItem
_thisMail.Send()

numAfterSent = objFolder.Items.Count

While Not numAfterSent numBeforeSent
If DateDiff(DateInterval.Second, loopStartTime, Date.Now) 30 Then
MsgBox("Unable to continue." & vbCrLf & "Reason: Unable to
find
the
email in the 'Sent Items' folder.", MsgBoxStyle.Critical)
Exit Function
Else
numAfterSent = objFolder.Items.Count
End If

End While

'''''''ONLY WORKS IN NON-CACHE MODE
sentItem.Item = objFolder.Items.GetFirst


How can I get the latest e-mail delivered to the Sent Items folder
if I
am
in Cache mode?








 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Cache Mode. Del Outlook - General Queries 3 December 19th 06 08:36 PM
Cache Mode Ed [MCT] Outlook - General Queries 2 November 6th 06 03:01 PM
how to determine if cache mode on or off Steve Paul Outlook - Installation 3 October 3rd 06 10:58 PM
Cache mode vs non cache mode Kofi Outlook - Installation 1 July 29th 06 04:08 AM
Cache Mode Waleed Outlook - Installation 0 May 28th 06 03:26 PM


All times are GMT +1. The time now is 09:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.