PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: HTML Item properties vs. Regular item properties
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: HTML Item properties vs. Regular item properties
![]() |
Re: HTML Item properties vs. Regular item properties |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Please show your code. Are you sure the date/time properties are the same?
Due to the roundoff errors, you should never expect an exact match, but rather check that the difference between two values is less than some value (e.g. millisecond). Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rayo K" <RayoK@discussions.microsoft.com> wrote in message news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... > Hello, > > I have a macro that is supposed to check my HTTP MSN acount for any sent > emails that are not already in my OUtlook folder "Sent Items". I compare > them > by checking the sent time and subject. However, the code seems to treat > the > properties as 'not equal' even when it's the same email. Is there > something > about being on a HTTP server that affects the item properties such that > they > will evaluate as not equal? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
I doubt it is possible.
Have you tried to modify the line If item1.SentOn = item2.SentOn Then to something like If Abs(item1.SentOn, item2.SentOn) < 1/24/60/60 Then Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rayo K" <RayoK@discussions.microsoft.com> wrote in message news:1F106CCB-C964-4A19-AB72-93981D6192EE@microsoft.com... >I have found something. The problem seems to be with emails that are >replies > or Fwds. In one case the SentOn and Subject properties return those of the > reply or forward, and in the other they return the properties of the > original > email. > > Now, how do I specify that the property should be from the reply/forward? > > "Dmitry Streblechenko" wrote: > >> Please show your code. Are you sure the date/time properties are the >> same? >> Due to the roundoff errors, you should never expect an exact match, but >> rather check that the difference between two values is less than some >> value >> (e.g. millisecond). >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... >> > Hello, >> > >> > I have a macro that is supposed to check my HTTP MSN acount for any >> > sent >> > emails that are not already in my OUtlook folder "Sent Items". I >> > compare >> > them >> > by checking the sent time and subject. However, the code seems to treat >> > the >> > properties as 'not equal' even when it's the same email. Is there >> > something >> > about being on a HTTP server that affects the item properties such that >> > they >> > will evaluate as not equal? >> >> >> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Outlook shows time rounded to the next minute, e.g. "12/20/2006 3:37:56:135"
will be displayed as "12/20/2006 3:38" by Outlook, the same as "12/20/2006 3:37:56:142" while the values are clearly diferent under the hood. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rayo K" <RayoK@discussions.microsoft.com> wrote in message news:43C3FE7C-02C1-450E-8EBF-DA715E67405F@microsoft.com... >I tried the code you suggested and it now copies several emails which it > wasn't copying before, and they all show the same time. > > "Dmitry Streblechenko" wrote: > >> I doubt it is possible. >> Have you tried to modify the line >> >> If item1.SentOn = item2.SentOn Then >> >> to something like >> >> If Abs(item1.SentOn, item2.SentOn) < 1/24/60/60 Then >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> news:1F106CCB-C964-4A19-AB72-93981D6192EE@microsoft.com... >> >I have found something. The problem seems to be with emails that are >> >replies >> > or Fwds. In one case the SentOn and Subject properties return those of >> > the >> > reply or forward, and in the other they return the properties of the >> > original >> > email. >> > >> > Now, how do I specify that the property should be from the >> > reply/forward? >> > >> > "Dmitry Streblechenko" wrote: >> > >> >> Please show your code. Are you sure the date/time properties are the >> >> same? >> >> Due to the roundoff errors, you should never expect an exact match, >> >> but >> >> rather check that the difference between two values is less than some >> >> value >> >> (e.g. millisecond). >> >> >> >> Dmitry Streblechenko (MVP) >> >> http://www.dimastr.com/ >> >> OutlookSpy - Outlook, CDO >> >> and MAPI Developer Tool >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... >> >> > Hello, >> >> > >> >> > I have a macro that is supposed to check my HTTP MSN acount for any >> >> > sent >> >> > emails that are not already in my OUtlook folder "Sent Items". I >> >> > compare >> >> > them >> >> > by checking the sent time and subject. However, the code seems to >> >> > treat >> >> > the >> >> > properties as 'not equal' even when it's the same email. Is there >> >> > something >> >> > about being on a HTTP server that affects the item properties such >> >> > that >> >> > they >> >> > will evaluate as not equal? >> >> >> >> >> >> >> >> >> |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Why would they be the same? How do you end up with two copies of the same
message to begin with? Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rayo K" <RayoK@discussions.microsoft.com> wrote in message news:4CDCE0D1-B2BA-4E9E-99AC-3FCB072CCBB9@microsoft.com... > Ah ha! I see what I did wrong. I forgot to change the section of code > that > sorted the emails when the first sent time was greater than the second. > Here > is my modified code, which is working for now. However, I must keep > calibrating the time threshhold for the difference betwen recorded Sent > times. Thank you! > > However, I still don't understand why the sent times would be different in > the first place. Why would Outlook record different times for the HTTP > folder > and the default folder? > > Sub CopyEmails() > 'Written by Rayo Kumana 11/20/06 > 'handles for manipulated objects > Dim app As Outlook.Application > Dim space As NameSpace > Dim box1 As MAPIFolder > Dim box2 As MAPIFolder > Dim folder1 As MAPIFolder > Dim folder2 As MAPIFolder > Dim itemcoll1 As Items > Dim itemcoll2 As Items > Dim item1 As Object > Dim item2 As Object > Dim itemCopy As Object > > Dim x As Integer, y As Integer > Dim bookmark As Integer > Dim numItems As Integer > Dim totalCopied As Integer > Dim FCont As Boolean > > Dim TimeThresh As Date > > 'TimeThreshhold is an approximate gate for the difference in time _ > between the HTTP folder's SentOn and the Default folder's SentOn. > 'It should be set more than the max error between SentOn values _ > but less than the minimum expected time between sending two emails. > TimeThresh = 1 / 24 / 60 / 6 > 'It is currently set to 10 seconds > > > 'define the handles > Set app = CreateObject("Outlook.Application") > Set space = app.GetNamespace("MAPI") > Set box1 = space.Folders("MSN") > Set folder1 = box1.Folders("Sent Items") > Set box2 = space.Folders("Test1") > Set folder2 = box2.Folders("Sent Items") > Set itemcoll1 = folder1.Items > Set itemcoll2 = folder2.Items > > 'sort items collections by send date > itemcoll1.Sort "[SentOn]", True > itemcoll2.Sort "[SentOn]", True > > > 'step through all items in collection 1 > numItems = itemcoll1.Count > totalCopied = 0 > y = 1 > 'bookmark marks the last y corresponding to the last time checked. It > keeps > from checking later emails over and over again. > bookmark = 1 > > For x = 1 To numItems > 'Set item1 to the new key, set y to the first index and turn on the > continue > flag. > 'Really, I should be able to start at the last index because the keys were > also sorted, _ > but I'm not comfortable with that yet. The = code could advance the index > too far. > Set item1 = itemcoll1(x) > y = bookmark > FCont = True > > 'go through items in folder 2 > Do While FCont > 'For each iteration, the routine looks at the recevied time for item1 > (the key) _ > and item2 (the indexed item). > 'The indexed item cycles through from last received to first. If the > key > time is greater _ > then the key must not be in the index - otherwise it would would been > equal to a prior index. > 'If it is earlier than the index, we cycle back until we find an index > that it is greater _ > or equal to. > > > 'If there is no item corresponding to y, then we checked every index > and > the email _ > is not in the folder. > If y > itemcoll2.Count Then > 'If the server is not connected, it will not copy the email > On Error Resume Next > Set itemCopy = item1.Copy > If Err.Number Then > itemCopy.Delete > MsgBox "An error occurred while copying an item. Check that the > folder is online.", vbOKOnly, "Terminate" > GoTo Fin > Else > itemCopy.Move folder2 > CompareItem item1, item2 > totalCopied = totalCopied + 1 > > End If > > bookmark = y > Exit Do > End If > 'Now we set the index to the new y > Set item2 = itemcoll2(y) > > 'If the sent time is greater than the item in folder 2, the email is > new _ > and will be moved > If item1.SentOn > (item2.SentOn + TimeThresh) Then > 'Turn off the continue flag and copy the item > FCont = False > 'If the server is not connected, it will not copy the email > On Error Resume Next > Set itemCopy = item1.Copy > If Err.Number Then > itemCopy.Delete > MsgBox "An error occurred while copying an item. Check that the > folder is online.", vbOKOnly, "Terminate" > GoTo Fin > Else > itemCopy.Move folder2 > totalCopied = totalCopied + 1 > End If > bookmark = y > End If > > > If Abs(item1.SentOn - item2.SentOn) < TimeThresh Then > 'We have an item within the time threshold of the key. The continue > flag is off and the copy flag is on. _ > 'Either it is the same email or we will copy it. > 'Either way, we will not continue with this key > FCont = False > > bookmark = y > > If Not (item1.Subject = item2.Subject) Then > 'If the subjects are different, copy the email > 'If the server is not connected, it will not copy the email > On Error Resume Next > Set itemCopy = item1.Copy > If Err.Number Then > itemCopy.Delete > MsgBox "An error occurred while copying an item. Check > that the folder is online.", vbOKOnly, "Terminate" > GoTo Fin > Else > itemCopy.Move folder2 > totalCopied = totalCopied + 1 > > End If > > End If > 'The continue flag is off either way, so the loop will terminate > > End If > > 'if the key is not greater than the index, and not the same, increment > the index by one. > y = y + 1 > Loop > > Next x > > > Fin: > MsgBox totalCopied & " e-mails copied.", vbOKOnly, "Copying e-mails > completed." > > End Sub > > > > > "Dmitry Streblechenko" wrote: > >> Outlook shows time rounded to the next minute, e.g. "12/20/2006 >> 3:37:56:135" >> will be displayed as "12/20/2006 3:38" by Outlook, the same as >> "12/20/2006 >> 3:37:56:142" while the values are clearly diferent under the hood. >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> news:43C3FE7C-02C1-450E-8EBF-DA715E67405F@microsoft.com... >> >I tried the code you suggested and it now copies several emails which it >> > wasn't copying before, and they all show the same time. >> > >> > "Dmitry Streblechenko" wrote: >> > >> >> I doubt it is possible. >> >> Have you tried to modify the line >> >> >> >> If item1.SentOn = item2.SentOn Then >> >> >> >> to something like >> >> >> >> If Abs(item1.SentOn, item2.SentOn) < 1/24/60/60 Then >> >> >> >> Dmitry Streblechenko (MVP) >> >> http://www.dimastr.com/ >> >> OutlookSpy - Outlook, CDO >> >> and MAPI Developer Tool >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> news:1F106CCB-C964-4A19-AB72-93981D6192EE@microsoft.com... >> >> >I have found something. The problem seems to be with emails that are >> >> >replies >> >> > or Fwds. In one case the SentOn and Subject properties return those >> >> > of >> >> > the >> >> > reply or forward, and in the other they return the properties of the >> >> > original >> >> > email. >> >> > >> >> > Now, how do I specify that the property should be from the >> >> > reply/forward? >> >> > >> >> > "Dmitry Streblechenko" wrote: >> >> > >> >> >> Please show your code. Are you sure the date/time properties are >> >> >> the >> >> >> same? >> >> >> Due to the roundoff errors, you should never expect an exact match, >> >> >> but >> >> >> rather check that the difference between two values is less than >> >> >> some >> >> >> value >> >> >> (e.g. millisecond). >> >> >> >> >> >> Dmitry Streblechenko (MVP) >> >> >> http://www.dimastr.com/ >> >> >> OutlookSpy - Outlook, CDO >> >> >> and MAPI Developer Tool >> >> >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> >> news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... >> >> >> > Hello, >> >> >> > >> >> >> > I have a macro that is supposed to check my HTTP MSN acount for >> >> >> > any >> >> >> > sent >> >> >> > emails that are not already in my OUtlook folder "Sent Items". I >> >> >> > compare >> >> >> > them >> >> >> > by checking the sent time and subject. However, the code seems to >> >> >> > treat >> >> >> > the >> >> >> > properties as 'not equal' even when it's the same email. Is there >> >> >> > something >> >> >> > about being on a HTTP server that affects the item properties >> >> >> > such >> >> >> > that >> >> >> > they >> >> >> > will evaluate as not equal? >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
They would be the same, because when sending an email from an MSN account
through Outlook, the sent message is copied to the default Sent Items folder as well as the Sent Items folder on the MSN server. Thus two copies of the same message exist for every email sent when MSN is accessed via outlook. Except, for some reason, the SentOn time is actually different for the two copies. "Dmitry Streblechenko" wrote: > Why would they be the same? How do you end up with two copies of the same > message to begin with? > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > "Rayo K" <RayoK@discussions.microsoft.com> wrote in message > news:4CDCE0D1-B2BA-4E9E-99AC-3FCB072CCBB9@microsoft.com... > > Ah ha! I see what I did wrong. I forgot to change the section of code > > that > > sorted the emails when the first sent time was greater than the second. > > Here > > is my modified code, which is working for now. However, I must keep > > calibrating the time threshhold for the difference betwen recorded Sent > > times. Thank you! > > > > However, I still don't understand why the sent times would be different in > > the first place. Why would Outlook record different times for the HTTP > > folder > > and the default folder? > > > > Sub CopyEmails() > > 'Written by Rayo Kumana 11/20/06 > > 'handles for manipulated objects > > Dim app As Outlook.Application > > Dim space As NameSpace > > Dim box1 As MAPIFolder > > Dim box2 As MAPIFolder > > Dim folder1 As MAPIFolder > > Dim folder2 As MAPIFolder > > Dim itemcoll1 As Items > > Dim itemcoll2 As Items > > Dim item1 As Object > > Dim item2 As Object > > Dim itemCopy As Object > > > > Dim x As Integer, y As Integer > > Dim bookmark As Integer > > Dim numItems As Integer > > Dim totalCopied As Integer > > Dim FCont As Boolean > > > > Dim TimeThresh As Date > > > > 'TimeThreshhold is an approximate gate for the difference in time _ > > between the HTTP folder's SentOn and the Default folder's SentOn. > > 'It should be set more than the max error between SentOn values _ > > but less than the minimum expected time between sending two emails. > > TimeThresh = 1 / 24 / 60 / 6 > > 'It is currently set to 10 seconds > > > > > > 'define the handles > > Set app = CreateObject("Outlook.Application") > > Set space = app.GetNamespace("MAPI") > > Set box1 = space.Folders("MSN") > > Set folder1 = box1.Folders("Sent Items") > > Set box2 = space.Folders("Test1") > > Set folder2 = box2.Folders("Sent Items") > > Set itemcoll1 = folder1.Items > > Set itemcoll2 = folder2.Items > > > > 'sort items collections by send date > > itemcoll1.Sort "[SentOn]", True > > itemcoll2.Sort "[SentOn]", True > > > > > > 'step through all items in collection 1 > > numItems = itemcoll1.Count > > totalCopied = 0 > > y = 1 > > 'bookmark marks the last y corresponding to the last time checked. It > > keeps > > from checking later emails over and over again. > > bookmark = 1 > > > > For x = 1 To numItems > > 'Set item1 to the new key, set y to the first index and turn on the > > continue > > flag. > > 'Really, I should be able to start at the last index because the keys were > > also sorted, _ > > but I'm not comfortable with that yet. The = code could advance the index > > too far. > > Set item1 = itemcoll1(x) > > y = bookmark > > FCont = True > > > > 'go through items in folder 2 > > Do While FCont > > 'For each iteration, the routine looks at the recevied time for item1 > > (the key) _ > > and item2 (the indexed item). > > 'The indexed item cycles through from last received to first. If the > > key > > time is greater _ > > then the key must not be in the index - otherwise it would would been > > equal to a prior index. > > 'If it is earlier than the index, we cycle back until we find an index > > that it is greater _ > > or equal to. > > > > > > 'If there is no item corresponding to y, then we checked every index > > and > > the email _ > > is not in the folder. > > If y > itemcoll2.Count Then > > 'If the server is not connected, it will not copy the email > > On Error Resume Next > > Set itemCopy = item1.Copy > > If Err.Number Then > > itemCopy.Delete > > MsgBox "An error occurred while copying an item. Check that the > > folder is online.", vbOKOnly, "Terminate" > > GoTo Fin > > Else > > itemCopy.Move folder2 > > CompareItem item1, item2 > > totalCopied = totalCopied + 1 > > > > End If > > > > bookmark = y > > Exit Do > > End If > > 'Now we set the index to the new y > > Set item2 = itemcoll2(y) > > > > 'If the sent time is greater than the item in folder 2, the email is > > new _ > > and will be moved > > If item1.SentOn > (item2.SentOn + TimeThresh) Then > > 'Turn off the continue flag and copy the item > > FCont = False > > 'If the server is not connected, it will not copy the email > > On Error Resume Next > > Set itemCopy = item1.Copy > > If Err.Number Then > > itemCopy.Delete > > MsgBox "An error occurred while copying an item. Check that the > > folder is online.", vbOKOnly, "Terminate" > > GoTo Fin > > Else > > itemCopy.Move folder2 > > totalCopied = totalCopied + 1 > > End If > > bookmark = y > > End If > > > > > > If Abs(item1.SentOn - item2.SentOn) < TimeThresh Then > > 'We have an item within the time threshold of the key. The continue > > flag is off and the copy flag is on. _ > > 'Either it is the same email or we will copy it. > > 'Either way, we will not continue with this key > > FCont = False > > > > bookmark = y > > > > If Not (item1.Subject = item2.Subject) Then > > 'If the subjects are different, copy the email > > 'If the server is not connected, it will not copy the email > > On Error Resume Next > > Set itemCopy = item1.Copy > > If Err.Number Then > > itemCopy.Delete > > MsgBox "An error occurred while copying an item. Check > > that the folder is online.", vbOKOnly, "Terminate" > > GoTo Fin > > Else > > itemCopy.Move folder2 > > totalCopied = totalCopied + 1 > > > > End If > > > > End If > > 'The continue flag is off either way, so the loop will terminate > > > > End If > > > > 'if the key is not greater than the index, and not the same, increment > > the index by one. > > y = y + 1 > > Loop > > > > Next x > > > > > > Fin: > > MsgBox totalCopied & " e-mails copied.", vbOKOnly, "Copying e-mails > > completed." > > > > End Sub > > > > > > > > > > "Dmitry Streblechenko" wrote: > > > >> Outlook shows time rounded to the next minute, e.g. "12/20/2006 > >> 3:37:56:135" > >> will be displayed as "12/20/2006 3:38" by Outlook, the same as > >> "12/20/2006 > >> 3:37:56:142" while the values are clearly diferent under the hood. > >> > >> Dmitry Streblechenko (MVP) > >> http://www.dimastr.com/ > >> OutlookSpy - Outlook, CDO > >> and MAPI Developer Tool > >> > >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message > >> news:43C3FE7C-02C1-450E-8EBF-DA715E67405F@microsoft.com... > >> >I tried the code you suggested and it now copies several emails which it > >> > wasn't copying before, and they all show the same time. > >> > > >> > "Dmitry Streblechenko" wrote: > >> > > >> >> I doubt it is possible. > >> >> Have you tried to modify the line > >> >> > >> >> If item1.SentOn = item2.SentOn Then > >> >> > >> >> to something like > >> >> > >> >> If Abs(item1.SentOn, item2.SentOn) < 1/24/60/60 Then > >> >> > >> >> Dmitry Streblechenko (MVP) > >> >> http://www.dimastr.com/ > >> >> OutlookSpy - Outlook, CDO > >> >> and MAPI Developer Tool > >> >> > >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message > >> >> news:1F106CCB-C964-4A19-AB72-93981D6192EE@microsoft.com... > >> >> >I have found something. The problem seems to be with emails that are > >> >> >replies > >> >> > or Fwds. In one case the SentOn and Subject properties return those > >> >> > of > >> >> > the > >> >> > reply or forward, and in the other they return the properties of the > >> >> > original > >> >> > email. > >> >> > > >> >> > Now, how do I specify that the property should be from the > >> >> > reply/forward? > >> >> > > >> >> > "Dmitry Streblechenko" wrote: > >> >> > > >> >> >> Please show your code. Are you sure the date/time properties are > >> >> >> the > >> >> >> same? > >> >> >> Due to the roundoff errors, you should never expect an exact match, > >> >> >> but > >> >> >> rather check that the difference between two values is less than > >> >> >> some > >> >> >> value > >> >> >> (e.g. millisecond). > >> >> >> > >> >> >> Dmitry Streblechenko (MVP) > >> >> >> http://www.dimastr.com/ > >> >> >> OutlookSpy - Outlook, CDO > >> >> >> and MAPI Developer Tool > >> >> >> > >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message > >> >> >> news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... > >> >> >> > Hello, > >> >> >> > > >> >> >> > I have a macro that is supposed to check my HTTP MSN acount for > >> >> >> > any > >> >> >> > sent > >> >> >> > emails that are not already in my OUtlook folder "Sent Items". I > >> >> >> > compare > >> >> >> > them > >> >> >> > by checking the sent time and subject. However, the code seems to > >> >> >> > treat > >> >> >> > the > >> >> >> > properties as 'not equal' even when it's the same email. Is there > >> >> >> > something > >> >> >> > about being on a HTTP server that affects the item properties > >> >> >> > such > >> >> >> > that > >> >> >> > they > >> >> >> > will evaluate as not equal? > >> >> >> > >> >> >> > >> >> >> > >> >> > >> >> > >> >> > >> > >> > >> > > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
I don't use the MSN provider, but AFAIK the date in the default store's is
set based on the local time, while the messages in the MSN store are downloaded back from the MSN server and the dates are set based on the server time, which can be different (even within seconds) from the local time. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rayo K" <RayoK@discussions.microsoft.com> wrote in message news:FEB6C6F0-F42D-4AF1-A801-B4767A3956F7@microsoft.com... > They would be the same, because when sending an email from an MSN account > through Outlook, the sent message is copied to the default Sent Items > folder > as well as the Sent Items folder on the MSN server. Thus two copies of the > same message exist for every email sent when MSN is accessed via outlook. > > Except, for some reason, the SentOn time is actually different for the two > copies. > > "Dmitry Streblechenko" wrote: > >> Why would they be the same? How do you end up with two copies of the same >> message to begin with? >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> news:4CDCE0D1-B2BA-4E9E-99AC-3FCB072CCBB9@microsoft.com... >> > Ah ha! I see what I did wrong. I forgot to change the section of code >> > that >> > sorted the emails when the first sent time was greater than the second. >> > Here >> > is my modified code, which is working for now. However, I must keep >> > calibrating the time threshhold for the difference betwen recorded Sent >> > times. Thank you! >> > >> > However, I still don't understand why the sent times would be different >> > in >> > the first place. Why would Outlook record different times for the HTTP >> > folder >> > and the default folder? >> > >> > Sub CopyEmails() >> > 'Written by Rayo Kumana 11/20/06 >> > 'handles for manipulated objects >> > Dim app As Outlook.Application >> > Dim space As NameSpace >> > Dim box1 As MAPIFolder >> > Dim box2 As MAPIFolder >> > Dim folder1 As MAPIFolder >> > Dim folder2 As MAPIFolder >> > Dim itemcoll1 As Items >> > Dim itemcoll2 As Items >> > Dim item1 As Object >> > Dim item2 As Object >> > Dim itemCopy As Object >> > >> > Dim x As Integer, y As Integer >> > Dim bookmark As Integer >> > Dim numItems As Integer >> > Dim totalCopied As Integer >> > Dim FCont As Boolean >> > >> > Dim TimeThresh As Date >> > >> > 'TimeThreshhold is an approximate gate for the difference in time _ >> > between the HTTP folder's SentOn and the Default folder's SentOn. >> > 'It should be set more than the max error between SentOn values _ >> > but less than the minimum expected time between sending two emails. >> > TimeThresh = 1 / 24 / 60 / 6 >> > 'It is currently set to 10 seconds >> > >> > >> > 'define the handles >> > Set app = CreateObject("Outlook.Application") >> > Set space = app.GetNamespace("MAPI") >> > Set box1 = space.Folders("MSN") >> > Set folder1 = box1.Folders("Sent Items") >> > Set box2 = space.Folders("Test1") >> > Set folder2 = box2.Folders("Sent Items") >> > Set itemcoll1 = folder1.Items >> > Set itemcoll2 = folder2.Items >> > >> > 'sort items collections by send date >> > itemcoll1.Sort "[SentOn]", True >> > itemcoll2.Sort "[SentOn]", True >> > >> > >> > 'step through all items in collection 1 >> > numItems = itemcoll1.Count >> > totalCopied = 0 >> > y = 1 >> > 'bookmark marks the last y corresponding to the last time checked. It >> > keeps >> > from checking later emails over and over again. >> > bookmark = 1 >> > >> > For x = 1 To numItems >> > 'Set item1 to the new key, set y to the first index and turn on the >> > continue >> > flag. >> > 'Really, I should be able to start at the last index because the keys >> > were >> > also sorted, _ >> > but I'm not comfortable with that yet. The = code could advance the >> > index >> > too far. >> > Set item1 = itemcoll1(x) >> > y = bookmark >> > FCont = True >> > >> > 'go through items in folder 2 >> > Do While FCont >> > 'For each iteration, the routine looks at the recevied time for >> > item1 >> > (the key) _ >> > and item2 (the indexed item). >> > 'The indexed item cycles through from last received to first. If the >> > key >> > time is greater _ >> > then the key must not be in the index - otherwise it would would >> > been >> > equal to a prior index. >> > 'If it is earlier than the index, we cycle back until we find an >> > index >> > that it is greater _ >> > or equal to. >> > >> > >> > 'If there is no item corresponding to y, then we checked every index >> > and >> > the email _ >> > is not in the folder. >> > If y > itemcoll2.Count Then >> > 'If the server is not connected, it will not copy the email >> > On Error Resume Next >> > Set itemCopy = item1.Copy >> > If Err.Number Then >> > itemCopy.Delete >> > MsgBox "An error occurred while copying an item. Check that >> > the >> > folder is online.", vbOKOnly, "Terminate" >> > GoTo Fin >> > Else >> > itemCopy.Move folder2 >> > CompareItem item1, item2 >> > totalCopied = totalCopied + 1 >> > >> > End If >> > >> > bookmark = y >> > Exit Do >> > End If >> > 'Now we set the index to the new y >> > Set item2 = itemcoll2(y) >> > >> > 'If the sent time is greater than the item in folder 2, the email is >> > new _ >> > and will be moved >> > If item1.SentOn > (item2.SentOn + TimeThresh) Then >> > 'Turn off the continue flag and copy the item >> > FCont = False >> > 'If the server is not connected, it will not copy the email >> > On Error Resume Next >> > Set itemCopy = item1.Copy >> > If Err.Number Then >> > itemCopy.Delete >> > MsgBox "An error occurred while copying an item. Check that >> > the >> > folder is online.", vbOKOnly, "Terminate" >> > GoTo Fin >> > Else >> > itemCopy.Move folder2 >> > totalCopied = totalCopied + 1 >> > End If >> > bookmark = y >> > End If >> > >> > >> > If Abs(item1.SentOn - item2.SentOn) < TimeThresh Then >> > 'We have an item within the time threshold of the key. The >> > continue >> > flag is off and the copy flag is on. _ >> > 'Either it is the same email or we will copy it. >> > 'Either way, we will not continue with this key >> > FCont = False >> > >> > bookmark = y >> > >> > If Not (item1.Subject = item2.Subject) Then >> > 'If the subjects are different, copy the email >> > 'If the server is not connected, it will not copy the email >> > On Error Resume Next >> > Set itemCopy = item1.Copy >> > If Err.Number Then >> > itemCopy.Delete >> > MsgBox "An error occurred while copying an item. Check >> > that the folder is online.", vbOKOnly, "Terminate" >> > GoTo Fin >> > Else >> > itemCopy.Move folder2 >> > totalCopied = totalCopied + 1 >> > >> > End If >> > >> > End If >> > 'The continue flag is off either way, so the loop will terminate >> > >> > End If >> > >> > 'if the key is not greater than the index, and not the same, >> > increment >> > the index by one. >> > y = y + 1 >> > Loop >> > >> > Next x >> > >> > >> > Fin: >> > MsgBox totalCopied & " e-mails copied.", vbOKOnly, "Copying e-mails >> > completed." >> > >> > End Sub >> > >> > >> > >> > >> > "Dmitry Streblechenko" wrote: >> > >> >> Outlook shows time rounded to the next minute, e.g. "12/20/2006 >> >> 3:37:56:135" >> >> will be displayed as "12/20/2006 3:38" by Outlook, the same as >> >> "12/20/2006 >> >> 3:37:56:142" while the values are clearly diferent under the hood. >> >> >> >> Dmitry Streblechenko (MVP) >> >> http://www.dimastr.com/ >> >> OutlookSpy - Outlook, CDO >> >> and MAPI Developer Tool >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> news:43C3FE7C-02C1-450E-8EBF-DA715E67405F@microsoft.com... >> >> >I tried the code you suggested and it now copies several emails which >> >> >it >> >> > wasn't copying before, and they all show the same time. >> >> > >> >> > "Dmitry Streblechenko" wrote: >> >> > >> >> >> I doubt it is possible. >> >> >> Have you tried to modify the line >> >> >> >> >> >> If item1.SentOn = item2.SentOn Then >> >> >> >> >> >> to something like >> >> >> >> >> >> If Abs(item1.SentOn, item2.SentOn) < 1/24/60/60 Then >> >> >> >> >> >> Dmitry Streblechenko (MVP) >> >> >> http://www.dimastr.com/ >> >> >> OutlookSpy - Outlook, CDO >> >> >> and MAPI Developer Tool >> >> >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> >> news:1F106CCB-C964-4A19-AB72-93981D6192EE@microsoft.com... >> >> >> >I have found something. The problem seems to be with emails that >> >> >> >are >> >> >> >replies >> >> >> > or Fwds. In one case the SentOn and Subject properties return >> >> >> > those >> >> >> > of >> >> >> > the >> >> >> > reply or forward, and in the other they return the properties of >> >> >> > the >> >> >> > original >> >> >> > email. >> >> >> > >> >> >> > Now, how do I specify that the property should be from the >> >> >> > reply/forward? >> >> >> > >> >> >> > "Dmitry Streblechenko" wrote: >> >> >> > >> >> >> >> Please show your code. Are you sure the date/time properties are >> >> >> >> the >> >> >> >> same? >> >> >> >> Due to the roundoff errors, you should never expect an exact >> >> >> >> match, >> >> >> >> but >> >> >> >> rather check that the difference between two values is less than >> >> >> >> some >> >> >> >> value >> >> >> >> (e.g. millisecond). >> >> >> >> >> >> >> >> Dmitry Streblechenko (MVP) >> >> >> >> http://www.dimastr.com/ >> >> >> >> OutlookSpy - Outlook, CDO >> >> >> >> and MAPI Developer Tool >> >> >> >> >> >> >> >> "Rayo K" <RayoK@discussions.microsoft.com> wrote in message >> >> >> >> news:E70C617C-4F91-4A91-B1EC-C5498BA65C46@microsoft.com... >> >> >> >> > Hello, >> >> >> >> > >> >> >> >> > I have a macro that is supposed to check my HTTP MSN acount >> >> >> >> > for >> >> >> >> > any >> >> >> >> > sent >> >> >> >> > emails that are not already in my OUtlook folder "Sent Items". >> >> >> >> > I >> >> >> >> > compare >> >> >> >> > them >> >> >> >> > by checking the sent time and subject. However, the code seems >> >> >> >> > to >> >> >> >> > treat >> >> >> >> > the >> >> >> >> > properties as 'not equal' even when it's the same email. Is >> >> >> >> > there >> >> >> >> > something >> >> >> >> > about being on a HTTP server that affects the item properties >> >> >> >> > such >> >> >> >> > that >> >> >> >> > they >> >> >> >> > will evaluate as not equal? >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

