none
Capturing sent email from SentItems folder RRS feed

  • Question

  • Hello

    I am capturing ItemAdd event on SentItems folder. What i want to do is to capture the sent email after i hit send button. Here is what i am doing. I read that "itms.Item(itms.Count)" will get you the new sent item from the sentitems folder. This works fine if the Outlook version is Standard 2003 SP3 (Internal Version - 118330). In case of Outlook Professional 2003 (Internal Version - 118010) the same statement behaves differently. It returns oldest sent item from the sentitems folder and itms.Item(1) returns the new sent item.

    How can i get the last sentitem irrespective of outlook version? Or do i need to check for the outlook internal version and use different index to get the sent items?

    Thank You for your help.

    -----------------

    Dim

    olMail As Outlook.MailItem

     

    Try

     

    If TypeOf itms.Item(itms.Count) Is Outlook.MailItem Then

       olMail = itms.Item(itms.Count)

     

       CallForm(olMail)

    End If

     

    Catch ex As Exception

     

    Finally

     

       olMail = Nothing

     

    End Try

    ----------- 

    Thanks

    V

    Friday, May 27, 2011 12:32 PM

Answers

  • There is no guarantee how items are sorted in any particular folder. That has nothing to do with Outlook version. The algorithm you are using is flawed.
     
    If you are handling ItemAdd() on the Sent Items folder you already are getting a handle to the newly added item, what more do you need? Just use the Item passed to you in ItemAdd().

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "V2011" <=?utf-8?B?VjIwMTE=?=> wrote in message news:796da71e-45d8-4d86-9ccb-c4414471f1b0...

    Hello

    I am capturing ItemAdd event on SentItems folder. What i want to do is to capture the sent email after i hit send button. Here is what i am doing. I read that "itms.Item(itms.Count)" will get you the new sent item from the sentitems folder. This works fine if the Outlook version is Standard 2003 SP3 (Internal Version - 118330). In case of Outlook Professional 2003 (Internal Version - 118010) the same statement behaves differently. It returns oldest sent item from the sentitems folder and itms.Item(1) returns the new sent item.

    How can i get the last sentitem irrespective of outlook version? Or do i need to check for the outlook internal version and use different index to get the sent items?

    Thank You for your help.

    -----------------

    Dim

    olMail As Outlook.MailItem

     

    Try

     

    If TypeOf itms.Item(itms.Count) Is Outlook.MailItem Then

       olMail = itms.Item(itms.Count)

     

       CallForm(olMail)

    End If

     

    Catch ex As Exception

     

    Finally

     

       olMail = Nothing

     

    End Try

    ----------- 

    Thanks

    V


    Ken Slovak MVP - Outlook
    Friday, May 27, 2011 2:13 PM