Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking outlook 'outbox' for specific email

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I have the following code
Code:
        Set oItems = oApp.GetNamespace("MAPI").GetDefaultFolder(olOutbox).Items
            
        ' Get first item
        Set oMsg = oItems.GetFirst
        
        ' Check if matches
        bFound = (oMsg.UserProperties.Item("EmailRef").Value = sEmailRef)
            
        ' Loop rest of outbox items
        Do While Not oMsg Is Nothing And Not bFound
            
            ' Get next item
            Set oMsg = oItems.GetNext
            
            ' Check if matches
            bFound = (oMsg.UserProperties.Item("EmailRef").Value = sEmailRef)
        Loop

Which in theory should work fine, however, I have found that as soon as I try to access the UserProperties collection on a message currrently sending, it errors with
-2147221228 : Outlook has already begun transmitting this message.

So does this mean it is impossible for me to check if the email being sent is the email I am interested in as you cannot access any properties of an email currently transmitting?

Would the only way to try to evaluate this would be by checking the outbox, if I get that error code and the email cannot be found in the sent items, assume the email being sent is the one I am after?

Your input is appreciated.

1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
So are you saying that user properites are available for items not being transmitted but are in the outbox?

Interesting... I am curious to know what you came up with here as this is definitely among the more obscure things to be looking at.
 
So are you saying that user properites are available for items not being transmitted but are in the outbox?

Yes, it does appear so, once an email is being transmitted, trying to access any of its properties will cause that error.

I have a working solution, that is being tested and I will make it available as an addition to my EmailWrapper FAQ, once it has been properly tested and is in a production environment, so I can be sure any bugs have ben ironed out.

I need to fully test that and place a dummy email in the outbox but have outlook diconnected so it doesn't try to transmit the email just to be sure, I'll keep you posted once the full testing has been done.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Just to confirm, I put outlook in 'offline' mode and removed the error handling.

It does allow you to retrieve 'UserProperties' from an email in the outbox that is not currently transmitting.

So good news on that front, but I have a mechanism for handling the error of transmitting anyway, so it's looking promising :)

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top