![]() |
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
|
|||
|
|||
![]()
Here is a smippet of the code;
If obj.Class = olMail Then MsgBox "Here" Set myMail = obj MsgBox myMail.Subject Set usrProperty = myMail.UserProperties MsgBox usrProperty.Count Set oSpam = usrProperty.Find("MySpam") 'MsgBox IsError(oSpam.Name) MsgBox IsObject(oSpam) End If This obj lies in a folder for which the MySpam field "exists in the folder." What exactly that means I do not know but let's assume it does because I am not getting the error "Field Unknown." But in the statement Set oSpam = usrProperty.Find("MySpam") I am not getting an error even when usrProperty.Count = 0. But the error comes in the following statement MsgBox IsError(oSpam.Name) which is Object variable or With block variable not set and Error number is H5B. This presents a problem. What I need is some way to capture the situation where "MySpam" has not been added to the UserProperties collection for a specific MailItem and the way I tried it was to raise an error with oSpam.Name but seems not to be capturable w/o a On Error Resume Next which I do not want to use.. The next statement resolves to True. Any ideas? -- George Hester _________________________________ |
#2
|
|||
|
|||
![]()
You need to check whether you get a valid object:
Set oSpam = usrProperty.Find("MySpam") if Not oSpam IsNothing Then ... A property added to the folder simply makes it available in the field chooser when you design a view. A message from that folder is not quaranteed to have that (or any other) property. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "George Hester" wrote in message ... Here is a smippet of the code; If obj.Class = olMail Then MsgBox "Here" Set myMail = obj MsgBox myMail.Subject Set usrProperty = myMail.UserProperties MsgBox usrProperty.Count Set oSpam = usrProperty.Find("MySpam") 'MsgBox IsError(oSpam.Name) MsgBox IsObject(oSpam) End If This obj lies in a folder for which the MySpam field "exists in the folder." What exactly that means I do not know but let's assume it does because I am not getting the error "Field Unknown." But in the statement Set oSpam = usrProperty.Find("MySpam") I am not getting an error even when usrProperty.Count = 0. But the error comes in the following statement MsgBox IsError(oSpam.Name) which is Object variable or With block variable not set and Error number is H5B. This presents a problem. What I need is some way to capture the situation where "MySpam" has not been added to the UserProperties collection for a specific MailItem and the way I tried it was to raise an error with oSpam.Name but seems not to be capturable w/o a On Error Resume Next which I do not want to use.. The next statement resolves to True. Any ideas? -- George Hester _________________________________ |
#3
|
|||
|
|||
![]()
I like yours better than what I saw at Microsoft's site. They used
If TypeName(oSpam) "Nothing" Then whereas you used If Not oSpam Is Nothing Then Thanks man. When you say, "A property added to the folder simply makes it available in the field chooser when you design a view." Does that mean I have to add that field by using the GUI or can I add the field programmatically? I thought that was what I was doing with the third argument in the MailItem.UserProperties.Add("MySpam", clYesNo, True, 1) but seems no. -- George Hester _________________________________ "Dmitry Streblechenko" wrote in message ... You need to check whether you get a valid object: Set oSpam = usrProperty.Find("MySpam") if Not oSpam IsNothing Then ... A property added to the folder simply makes it available in the field chooser when you design a view. A message from that folder is not quaranteed to have that (or any other) property. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "George Hester" wrote in message ... Here is a smippet of the code; If obj.Class = olMail Then MsgBox "Here" Set myMail = obj MsgBox myMail.Subject Set usrProperty = myMail.UserProperties MsgBox usrProperty.Count Set oSpam = usrProperty.Find("MySpam") 'MsgBox IsError(oSpam.Name) MsgBox IsObject(oSpam) End If This obj lies in a folder for which the MySpam field "exists in the folder." What exactly that means I do not know but let's assume it does because I am not getting the error "Field Unknown." But in the statement Set oSpam = usrProperty.Find("MySpam") I am not getting an error even when usrProperty.Count = 0. But the error comes in the following statement MsgBox IsError(oSpam.Name) which is Object variable or With block variable not set and Error number is H5B. This presents a problem. What I need is some way to capture the situation where "MySpam" has not been added to the UserProperties collection for a specific MailItem and the way I tried it was to raise an error with oSpam.Name but seems not to be capturable w/o a On Error Resume Next which I do not want to use.. The next statement resolves to True. Any ideas? -- George Hester _________________________________ |
#4
|
|||
|
|||
![]()
MailItem.UserProperties.Add is what you need to add a property to that
*particular* message. Other messages in the folder (or anywhere else) will not be affected. Don't forget to set the value and save the message: set Prop = MailItem.UserProperties.Add("MySpam", clYesNo, True, 1) Prop.Value = TRUE MailItem.Save Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "George Hester" wrote in message ... I like yours better than what I saw at Microsoft's site. They used If TypeName(oSpam) "Nothing" Then whereas you used If Not oSpam Is Nothing Then Thanks man. When you say, "A property added to the folder simply makes it available in the field chooser when you design a view." Does that mean I have to add that field by using the GUI or can I add the field programmatically? I thought that was what I was doing with the third argument in the MailItem.UserProperties.Add("MySpam", clYesNo, True, 1) but seems no. -- George Hester _________________________________ "Dmitry Streblechenko" wrote in message ... You need to check whether you get a valid object: Set oSpam = usrProperty.Find("MySpam") if Not oSpam IsNothing Then ... A property added to the folder simply makes it available in the field chooser when you design a view. A message from that folder is not quaranteed to have that (or any other) property. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "George Hester" wrote in message ... Here is a smippet of the code; If obj.Class = olMail Then MsgBox "Here" Set myMail = obj MsgBox myMail.Subject Set usrProperty = myMail.UserProperties MsgBox usrProperty.Count Set oSpam = usrProperty.Find("MySpam") 'MsgBox IsError(oSpam.Name) MsgBox IsObject(oSpam) End If This obj lies in a folder for which the MySpam field "exists in the folder." What exactly that means I do not know but let's assume it does because I am not getting the error "Field Unknown." But in the statement Set oSpam = usrProperty.Find("MySpam") I am not getting an error even when usrProperty.Count = 0. But the error comes in the following statement MsgBox IsError(oSpam.Name) which is Object variable or With block variable not set and Error number is H5B. This presents a problem. What I need is some way to capture the situation where "MySpam" has not been added to the UserProperties collection for a specific MailItem and the way I tried it was to raise an error with oSpam.Name but seems not to be capturable w/o a On Error Resume Next which I do not want to use.. The next statement resolves to True. Any ideas? -- George Hester _________________________________ |
#5
|
|||
|
|||
![]()
sorry Using Find in User Properties. Not Fing.
-- George Hester _________________________________ "George Hester" wrote in message ... Here is a smippet of the code; |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
UserProperties are missing on Appointment | [email protected] | Outlook - General Queries | 0 | February 8th 07 08:20 PM |
UserProperties for New Items | dch3 | Outlook and VBA | 2 | December 18th 06 06:46 PM |
Keep changed UserProperties when moving to different folder | Stefan Singer | Outlook - Using Forms | 5 | June 13th 06 12:25 PM |
VB.net Cannot add userproperties | Ben | Add-ins for Outlook | 2 | February 24th 06 10:32 AM |
Userproperties in Folder | MClaudio | Outlook and VBA | 3 | January 16th 06 07:59 AM |