![]() |
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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi
I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#2
|
|||
|
|||
![]()
Just a tip, with those nested IIF's that code will be a real mess to debug.
I'd unwrap it into a set of if blocks to make debugging easier. BTW, that is Outlook object model code, not Simple MAPI API calls. Define "many items in bulk" (how many, show the code to create them), define "behaves inconsistently". Always mention the Outlook and Window versions, and store type (PST files, Exchange, etc.). Do you get any exceptions? Set up try...catch blocks to trap any errors. Don't use multiple dot operators, especially in loops. Declare your object variables outside the loop avoid implicitly created objects that cannot be released. For example: Dim colItems As Outlook.Items = MyFolder.Items olitem = colItems.Add(olType) That way the Items collection can explicitly be released. That's especially important in loops and hugely so with Exchange, where there's an RPC channel limit. Exceeding that limit will cause exceptions, and implicitly created objects all use up RPC channels and can't be released. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#3
|
|||
|
|||
![]()
Hi ken,
Thanks for the prompt reply. To my surprise now, i found out that write works fine. We were looking for bug in wrong place, as after using MFCMapi tool, i found out that PR_lastmodification_time is updated. But while reading it do not read the updated time but the cached time. I am using the standard code to read LastModification time, suggested by microsoft in help document. Following is the code sample. ,,Private mobjOutlook As Microsoft.Office.Interop.Outlook.Application 'outlook application ,,Private mobjOlNs As Microsoft.Office.Interop.Outlook.NameSpace ' current namespace to work with ,,Private mobjApptMAPIFld As Microsoft.Office.Interop.Outlook.MAPIFolder ' current folder to work with calendar ,,,, mobjOlNs = mobjOutlook.GetNamespace("MAPI") ,,,, mobjApptMAPIFld = mobjOlNs.GetDefaultFolder(Microsoft.Office.Intero p.Outlook.OlDefaultFolders.olFolderCalendar) ,,,, mobjApptMAPIFld.Item[i].LastModificationTime// give the appointment Even if i logoff and logon session through code and use getitembyid property to retrived the idem detail, it gives me same unmodified date. Is there any api, though undocumented, which can be used to get the uncached last modification time ? Best Regards Ashish Rawat "Ken Slovak - [MVP - Outlook]" wrote: Just a tip, with those nested IIF's that code will be a real mess to debug. I'd unwrap it into a set of if blocks to make debugging easier. BTW, that is Outlook object model code, not Simple MAPI API calls. Define "many items in bulk" (how many, show the code to create them), define "behaves inconsistently". Always mention the Outlook and Window versions, and store type (PST files, Exchange, etc.). Do you get any exceptions? Set up try...catch blocks to trap any errors. Don't use multiple dot operators, especially in loops. Declare your object variables outside the loop avoid implicitly created objects that cannot be released. For example: Dim colItems As Outlook.Items = MyFolder.Items olitem = colItems.Add(olType) That way the Items collection can explicitly be released. That's especially important in loops and hugely so with Exchange, where there's an RPC channel limit. Exceeding that limit will cause exceptions, and implicitly created objects all use up RPC channels and can't be released. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#4
|
|||
|
|||
![]()
You didn't answer my questions. What do you mean by "Outlook becomes
unresponsive"? Even in Exchange cached mode you should be able to get the correct LastModificationTime value. Did you save the item when you made any changes to it before trying to read the changed LastModificationTime value? I would change that code you're using because it's still using multiple dot operators. I'd assign a specific Outlook item to mobjApptMAPIFld.Item[i] and then read LastModificationTime from that. I'd also set that object variable to Nothing each pass through the loop. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Ashish" wrote in message ...[i] Hi ken, Thanks for the prompt reply. To my surprise now, i found out that write works fine. We were looking for bug in wrong place, as after using MFCMapi tool, i found out that PR_lastmodification_time is updated. But while reading it do not read the updated time but the cached time. I am using the standard code to read LastModification time, suggested by microsoft in help document. Following is the code sample. ,,Private mobjOutlook As Microsoft.Office.Interop.Outlook.Application 'outlook application ,,Private mobjOlNs As Microsoft.Office.Interop.Outlook.NameSpace ' current namespace to work with ,,Private mobjApptMAPIFld As Microsoft.Office.Interop.Outlook.MAPIFolder ' current folder to work with calendar ,,,, mobjOlNs = mobjOutlook.GetNamespace("MAPI") ,,,, mobjApptMAPIFld = mobjOlNs.GetDefaultFolder(Microsoft.Office.Intero p.Outlook.OlDefaultFolders.olFolderCalendar) ,,,, mobjApptMAPIFld.Item.LastModificationTime// give the appointment Even if i logoff and logon session through code and use getitembyid property to retrived the idem detail, it gives me same unmodified date. Is there any api, though undocumented, which can be used to get the uncached last modification time ? Best Regards Ashish Rawat |
#5
|
|||
|
|||
![]()
Hi Ken,
Good point, when i said outlook is non responsive, i mean this issue itself, there is no other syntoms to see outlook is not working properly. Rest everything is outlook is going fine. Ofcouse, i save outlook item and then check the last modification date. I tried using tool like outlook spy tool, and something macro also. Also i created a sample program as follows. If InitOutlook() = True Then objMapiFolder = objNamespace.PickFolder objNamespace.Logoff() 'objNamespace.objNamespace.Logoff() ' objNamespace.Logon() ' objMapiFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFol ders.olFolderCalendar) If Not objMapiFolder Is Nothing Then oItems = objMapiFolder.Items For Each ocontact In oItems TextBox2.Text = TextBox2.Text + Environment.NewLine + " Subject : " + ocontact.Subject TextBox2.Text = TextBox2.Text + Environment.NewLine + " Last Modified time : " + ocontact.LastModificationTime Next End If Still it gives the incorrect logs. Best Regards Ashish Rawat "Ken Slovak - [MVP - Outlook]" wrote: [i] You didn't answer my questions. What do you mean by "Outlook becomes unresponsive"? Even in Exchange cached mode you should be able to get the correct LastModificationTime value. Did you save the item when you made any changes to it before trying to read the changed LastModificationTime value? I would change that code you're using because it's still using multiple dot operators. I'd assign a specific Outlook item to mobjApptMAPIFld.Item[i] and then read LastModificationTime from that. I'd also set that object variable to Nothing each pass through the loop. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Ashish" wrote in message ... Hi ken, Thanks for the prompt reply. To my surprise now, i found out that write works fine. We were looking for bug in wrong place, as after using MFCMapi tool, i found out that PR_lastmodification_time is updated. But while reading it do not read the updated time but the cached time. I am using the standard code to read LastModification time, suggested by microsoft in help document. Following is the code sample. ,,Private mobjOutlook As Microsoft.Office.Interop.Outlook.Application 'outlook application ,,Private mobjOlNs As Microsoft.Office.Interop.Outlook.NameSpace ' current namespace to work with ,,Private mobjApptMAPIFld As Microsoft.Office.Interop.Outlook.MAPIFolder ' current folder to work with calendar ,,,, mobjOlNs = mobjOutlook.GetNamespace("MAPI") ,,,, mobjApptMAPIFld = mobjOlNs.GetDefaultFolder(Microsoft.Office.Intero p.Outlook.OlDefaultFolders.olFolderCalendar) ,,,, mobjApptMAPIFld.Item.LastModificationTime// give the appointment Even if i logoff and logon session through code and use getitembyid property to retrived the idem detail, it gives me same unmodified date. Is there any api, though undocumented, which can be used to get the uncached last modification time ? Best Regards Ashish Rawat |
#6
|
|||
|
|||
![]()
I don't understand.
That sample code you show does nothing that would modify the items, therefore LastModificationTime is not going to change on any of the items. Also why are you using NameSpace.Logoff? There's no reason for that at all. This test VBA code shows what I mean. I selected a contact item and ran the macro. The modified times shown are 3/23/2009 at 8:50 AM before the subject is changed and 5/28/2009 at 1:39 PM afterwards. Sub ModifyItem() Dim oc As Outlook.ContactItem Set oc = Application.ActiveExplorer.Selection(1) Debug.Print oc.LastModificationTime oc.Subject = oc.Subject & " Test" oc.Save Debug.Print oc.LastModificationTime End Sub This code was run in an Outlook setup that uses cached mode, therefore demonstrating that cached mode has nothing to do with anything here. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Ashish" wrote in message ... Hi Ken, Good point, when i said outlook is non responsive, i mean this issue itself, there is no other syntoms to see outlook is not working properly. Rest everything is outlook is going fine. Ofcouse, i save outlook item and then check the last modification date. I tried using tool like outlook spy tool, and something macro also. Also i created a sample program as follows. If InitOutlook() = True Then objMapiFolder = objNamespace.PickFolder objNamespace.Logoff() 'objNamespace.objNamespace.Logoff() ' objNamespace.Logon() ' objMapiFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFol ders.olFolderCalendar) If Not objMapiFolder Is Nothing Then oItems = objMapiFolder.Items For Each ocontact In oItems TextBox2.Text = TextBox2.Text + Environment.NewLine + " Subject : " + ocontact.Subject TextBox2.Text = TextBox2.Text + Environment.NewLine + " Last Modified time : " + ocontact.LastModificationTime Next End If Still it gives the incorrect logs. Best Regards Ashish Rawat |
#7
|
|||
|
|||
![]()
" lastmodification time property will not get updated." - what exactly do
you mean by that? If you are creating a brand new item, surely you would get some value in the lastmodification time propety. What is it? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#8
|
|||
|
|||
![]() Hi Dimitry, We are talking about update scenario here. Best Regards Ashish rawat "Dmitry Streblechenko" wrote: " lastmodification time property will not get updated." - what exactly do you mean by that? If you are creating a brand new item, surely you would get some value in the lastmodification time propety. What is it? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#9
|
|||
|
|||
![]()
Hi Dimitri,
I didn't notices, am i taking to Dimitry , the father of redemption dll.I am honoured ![]() By the way, i have raised this issue as bug to microsoft also. Best Regards Ashish Rawat "Ashish" wrote: Hi Dimitry, We are talking about update scenario here. Best Regards Ashish rawat "Dmitry Streblechenko" wrote: " lastmodification time property will not get updated." - what exactly do you mean by that? If you are creating a brand new item, surely you would get some value in the lastmodification time propety. What is it? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
#10
|
|||
|
|||
![]()
So you see the chnage that your code makes but the last modified time stays
the same? Doyou have a sampel script that exhibits this porblem? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ashish" wrote in message ... Hi Dimitri, I didn't notices, am i taking to Dimitry , the father of redemption dll.I am honoured ![]() By the way, i have raised this issue as bug to microsoft also. Best Regards Ashish Rawat "Ashish" wrote: Hi Dimitry, We are talking about update scenario here. Best Regards Ashish rawat "Dmitry Streblechenko" wrote: " lastmodification time property will not get updated." - what exactly do you mean by that? If you are creating a brand new item, surely you would get some value in the lastmodification time propety. What is it? -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ashish" Ashish @discussions.microsoft.com wrote in message ... Hi I write outlook item using the simple MAPI api . Following is the code example. Dim MyFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim MyFileName As String Dim OlType As Microsoft.Office.Interop.Outlook.OlItemType Dim TypeSuffix As String Dim olitem as object OlType = GetCorrespondingOlItemType(CalType) TypeSuffix = GetCorrespondingSuffix(CalType) MyFolder = IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olTask Item, mobjTaskMAPIFld, IIf(OlType = Microsoft.Office.Interop.Outlook.OlItemType.olAppo intmentItem, mobjApptMAPIFld, mobjContactMAPIFld)) On Error GoTo OpenAsDefault Err.Clear() olitem= MyFolder.Items.Add(OlType) olitem.save System.Runtime.InteropServices.Marshal.FinalReleas eComObject(olitem) if a write many items in bulk, the oulook behaves inconsistently, Even if i create a new contact manually and update it, lastmodification time property will not get updated. Though this issue is not consistenly reporducible, can some help me finding any reason why this is happening ? Thanks in advance. Best Regards Ashish Rawat |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
outlook 2003 vista non responsive | Chris Heddins | Outlook - General Queries | 1 | April 1st 09 01:19 AM |
Item Write event is not always catched | Carsten Gehling | Add-ins for Outlook | 2 | January 24th 08 01:32 PM |
Outlook Express Not Responsive | carolpm | Outlook Express | 2 | May 18th 06 07:22 PM |
Outlook becomes non-responsive when I try to attach anything | Charlie | Outlook - Installation | 3 | April 21st 06 09:52 PM |
Can I write a message rule on the Envelope-to item? | Rauscher | Outlook Express | 4 | January 19th 06 08:22 PM |