A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Using Fing in UserProperties



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 11th 07, 05:46 PM posted to microsoft.public.outlook.program_vba
George Hester
external usenet poster
 
Posts: 54
Default Using Fing in UserProperties

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  
Old February 11th 07, 06:42 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Using Fing in UserProperties

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  
Old February 11th 07, 10:01 PM posted to microsoft.public.outlook.program_vba
George Hester
external usenet poster
 
Posts: 54
Default Using Fing in UserProperties

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  
Old February 11th 07, 10:39 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Using Fing in UserProperties

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  
Old February 11th 07, 06:22 PM posted to microsoft.public.outlook.program_vba
George Hester
external usenet poster
 
Posts: 54
Default Using Fing in UserProperties

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 12:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.