How to add an userpropertie to an email folder?

  • Thread starter Thread starter Peter Marchert
  • Start date Start date
P

Peter Marchert

Hello,

I tried several things but nothing works (create or add an item to the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).

The only way to add an userproperty to an email folder is to select an
existing item in the destination folder and then add the userproperty.

Does anybody has a solution for this problem?

Thanks in advance.

Peter
 
Peter, create an item in that folder (Items.Add). The UserPropteries.Add
function supports you with the AddToFolderFields property. When that's done
you can delete the item, the UserProperty remains in the folder.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
 
Hi Michael,

I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(

Peter
 
Do you use the new item returned by the MailItem.Move method or the old one
to add a folder property?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi Michael,

I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(

Peter
 
Thanks for your answer, Dmitry.

I try this code to add the userproperty and I now found out, that it
does not works with subfolders:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)

Call objMail.UserProperties.Add("MyTestProperty", olText)

objMail.Delete

End Sub

Peter
 
As you have already noticed, the new item will be created in the Drafts folder, you need to explicitly move the item to the target folder:

Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Thanks for your answer, Dmitry.

I try this code to add the userproperty and I now found out, that it
does not works with subfolders:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)

Call objMail.UserProperties.Add("MyTestProperty", olText)

objMail.Delete

End Sub

Peter
 
Hmm, I`m sorry, but this does not work:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

End Sub

There is no UserProperty "MyTestProperty" in the subfolder "test".

Peter

As you have already noticed, the new item will be created in the Drafts folder, you need to explicitly move the item to the target folder:

Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Thanks for your answer, Dmitry.

I try this code to add the userproperty and I now found out, that it
does not works with subfolders:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)

Call objMail.UserProperties.Add("MyTestProperty", olText)

objMail.Delete

End Sub

Peter

Do you use the new item returned by the MailItem.Move method or the oldone
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Peter Marchert" <[email protected]> wrote in message
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(

On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The UserPropteries.Add
function supports you with the AddToFolderFields property. When that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an item to the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to selectan
existing item in the destination folder and then add the userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenText ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Hmmm... Yes, I can still see the problem; don't why it worked for me
before...

<plug>
You can use Redemption ot add user fields to a folder - it does not try to
be "smart" and you do not need to create a dummy message just to add a
field:

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save

</plug>


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hmm, I`m sorry, but this does not work:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

End Sub

There is no UserProperty "MyTestProperty" in the subfolder "test".

Peter

As you have already noticed, the new item will be created in the Drafts
folder, you need to explicitly move the item to the target folder:

Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

message
Thanks for your answer, Dmitry.

I try this code to add the userproperty and I now found out, that it
does not works with subfolders:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)

Call objMail.UserProperties.Add("MyTestProperty", olText)

objMail.Delete

End Sub

Peter

Do you use the new item returned by the MailItem.Move method or the old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Peter Marchert" <[email protected]> wrote in message
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(

On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenText ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Hmmmm....that is a nice idea, but...

Sub TestUserProperty()

Dim strFilter As String

strFilter = "[MyTestProperty] <> """""

Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count

End Sub

Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.

Peter


Hmmm... Yes, I can still see the problem; don't why it worked for me
before...

<plug>
You can use Redemption ot add user fields to a folder - it does not try to
be "smart" and you do not need to create a dummy message just to add a
field:

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save

</plug>

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hmm, I`m sorry, but this does not work:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

End Sub

There is no UserProperty "MyTestProperty" in the subfolder "test".

Peter

As you have already noticed, the new item will be created in the Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, that it
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete

End Sub

Do you use the new item returned by the MailItem.Move method or the old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Do you see the added property after you switch the current folder and then
come back? How about restarting Outlook?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hmmmm....that is a nice idea, but...

Sub TestUserProperty()

Dim strFilter As String

strFilter = "[MyTestProperty] <> """""

Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count

End Sub

Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.

Peter


Hmmm... Yes, I can still see the problem; don't why it worked for me
before...

<plug>
You can use Redemption ot add user fields to a folder - it does not try to
be "smart" and you do not need to create a dummy message just to add a
field:

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save

</plug>

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hmm, I`m sorry, but this does not work:

Sub AddUserProperty()

Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem

Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)

Set objFolder = objInBox.Folders("test")

Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)

End Sub

There is no UserProperty "MyTestProperty" in the subfolder "test".

Peter

As you have already noticed, the new item will be created in the Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, that it
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete

End Sub

Do you use the new item returned by the MailItem.Move method or the
old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When
that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to
select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Yes, after switching to another folder the filed is present.

Is there any other way? I need to access the field directly after it
was created without folder switching.

Thanks,
Peter

Do you see the added property after you switch the current folder and then
come back? How about restarting Outlook?

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hmmmm....that is a nice idea, but...

Sub TestUserProperty()

Dim strFilter As String

strFilter = "[MyTestProperty] <> """""

Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count

End Sub

Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.

Peter

Hmmm... Yes, I can still see the problem; don't why it worked for me
before...
<plug>
You can use Redemption ot add user fields to a folder - it does not tryto
be "smart" and you do not need to create a dummy message just to add a
field:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Peter Marchert" <[email protected]> wrote in message
Hmm, I`m sorry, but this does not work:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
There is no UserProperty "MyTestProperty" in the subfolder "test".

As you have already noticed, the new item will be created in the Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
message
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, that it
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete
End Sub
Peter
Do you use the new item returned by the MailItem.Move method or the
old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When
that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an itemto
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to
select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden-
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Or is it possible with MapiTables to search for UserProperties in
Items? So It would not be necessary to create folder fields.

Peter

Yes, after switching to another folder the filed is present.

Is there any other way? I need to access the field directly after it
was created without folder switching.

Thanks,
Peter

Do you see the added property after you switch the current folder and then
come back? How about restarting Outlook?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Peter Marchert" <[email protected]> wrote in message
Hmmmm....that is a nice idea, but...
Sub TestUserProperty()
Dim strFilter As String
strFilter = "[MyTestProperty] <> """""
Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count

End Sub
Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.

Hmmm... Yes, I can still see the problem; don't why it worked for me
before...
<plug>
You can use Redemption ot add user fields to a folder - it does not try to
be "smart" and you do not need to create a dummy message just to add a
field:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save
</plug>
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hmm, I`m sorry, but this does not work:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
End Sub
There is no UserProperty "MyTestProperty" in the subfolder "test".
Peter
As you have already noticed, the new item will be created in the Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
message
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, that it
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete
End Sub
Peter
Do you use the new item returned by the MailItem.Move method or the
old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When
that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to
select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden-
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Are all references to the folder and user property objects released? If they
are it's just one of those Outlook things.

You can use a UserProperty as a column in a MAPITable and you can also
reference properties added to PS_PUBLIC_STRINGS that aren't user properties
or you can add your own properties using a unique GUID of your own as the
namespace instead of using PS_PUBLIC_STRINGS. Just use the correct GUID, tag
and property type when you set the column.




Or is it possible with MapiTables to search for UserProperties in
Items? So It would not be necessary to create folder fields.

Peter
 
Thank you Ken, I will try it with the MapiTables and perhaps with the
PS_PUBLIC_STRINGS.

Peter
 
Yes, MAPITable would not care less if a property is defined on the folder
level as long as you provide the right property tag

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Or is it possible with MapiTables to search for UserProperties in
Items? So It would not be necessary to create folder fields.

Peter

Yes, after switching to another folder the filed is present.

Is there any other way? I need to access the field directly after it
was created without folder switching.

Thanks,
Peter

Do you see the added property after you switch the current folder and
then
come back? How about restarting Outlook?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Peter Marchert" <[email protected]> wrote in message
Hmmmm....that is a nice idea, but...
Sub TestUserProperty()
Dim strFilter As String
strFilter = "[MyTestProperty] <> """""
Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count

End Sub
Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.

Hmmm... Yes, I can still see the problem; don't why it worked for me
before...
<plug>
You can use Redemption ot add user fields to a folder - it does not
try to
be "smart" and you do not need to create a dummy message just to add a
field:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save
</plug>
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hmm, I`m sorry, but this does not work:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
End Sub
There is no UserProperty "MyTestProperty" in the subfolder "test".
Peter
As you have already noticed, the new item will be created in the
Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
message
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, that it
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete
End Sub
Peter
Do you use the new item returned by the MailItem.Move method or
the
old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the
drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When
that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an
item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to
select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden-
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
Thank you Ken for the hint with the GUID. I tryed it and it seems to
work very good.

Thank you Dmitry for the Redemption.dll which is a great and very
helpful utility.

At least one more question: If I try to copy an item with an added
property from a write protected folder an error occurs (something like
"access problem"). The code to copy an item is this:

If Not objRDOItem Is Nothing Then Call
objRDOItem.CopyTo(objRDOFolder2)

In Outlook you can set a reference to a moved item e. g. Set objItem =
objItem.move(objFolder)

I tryed this for the RDOItem too, but this does not work: If Not
objRDOItem Is Nothing Then Set objRDOItem =
objRDOItem.CopyTo(objRDOFolder2)

Is there another method to get the reference of the copied item? If
so, I could add the property after I copied the item. If it is not
possible I would copy it to a temp folder, add the property and then
move it to the destination folder. But this is not very comfortable.

Peter

Yes, MAPITable would not care less if a property is defined on the folder
level as long as you provide the right property tag

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Or is it possible with MapiTables to search for UserProperties in
Items? So It would not be necessary to create folder fields.

Peter

Yes, after switching to another folder the filed is present.
Is there any other way? I need to access the field directly after it
was created without folder switching.
Thanks,
Peter

Do you see the added property after you switch the current folder and
then
come back? How about restarting Outlook?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hmmmm....that is a nice idea, but...
Sub TestUserProperty()
Dim strFilter As String
strFilter = "[MyTestProperty] <> """""
Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restrict(strFilter).Count
End Sub
Says that this property does not exists. In the fields selector in
Outlook it is not present but with RDO I can access the created field.
Peter
Hmmm... Yes, I can still see the problem; don't why it worked for me
before...
<plug>
You can use Redemption ot add user fields to a folder - it does not
try to
be "smart" and you do not need to create a dummy message just to add a
field:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderInbox).Folders("test")
set FolderFields = Folder.FolderFields
set Field = FolderFields.Add("MyTestProperty", olText)
FolderFields.Save
</plug>
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hmm, I`m sorry, but this does not work:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objInBox.Items.Add(objFolder.DefaultMessageClass)
Set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
End Sub
There is no UserProperty "MyTestProperty" in the subfolder "test".
Peter
As you have already noticed, the new item will be created in the
Drafts
folder, you need to explicitly move the item to the target folder:
Set objMail = objInBox .Items.Add(objFolder.DefaultMessageClass)
set objMail = objMail.Move(objFolder)
Call objMail.UserProperties.Add("MyTestProperty", olText)
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
message
Thanks for your answer, Dmitry.
I try this code to add the userproperty and I now found out, thatit
does not works with subfolders:
Sub AddUserProperty()
Dim objInBox As Outlook.MAPIFolder
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.MailItem
Set objInBox = Outlook.Session.GetDefaultFolder(olFolderInbox)
Set objFolder = objInBox.Folders("test")
Set objMail = objFolder.Items.Add(objFolder.DefaultMessageClass)
Call objMail.UserProperties.Add("MyTestProperty", olText)
objMail.Delete
End Sub
Peter
Do you use the new item returned by the MailItem.Move method or
the
old
one
to add a folder property?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Michael,
I cannot add an item to a specified email folder, it will always
created on the folder which is set for new items (normally the
drafts
folder). And moving from this folder to the destination folder and
then adding an userproperty will not work :-(
Peter
On 3 Sep., 07:29, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Peter, create an item in that folder (Items.Add). The
UserPropteries.Add
function supports you with the AddToFolderFields property. When
that's
done
you can delete the item, the UserProperty remains in the folder.
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Sun, 02 Sep 2007 07:15:25 -0700 schrieb Peter Marchert:
Hello,
I tried several things but nothing works (create or add an
item to
the
default drafts folder, move the item to the destination folder
(dereferencing the item) and then add the userproperty).
The only way to add an userproperty to an email folder is to
select
an
existing item in the destination folder and then add the
userproperty.
Does anybody has a solution for this problem?
Thanks in advance.
Peter
--
Infos, workshops & soft-
ware for your Outlook®:
www.outlook-stuff.com-ZitiertenTextausblenden-
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
 
CopyTo is a sub, it has no return value. item.Move is a function and returns
a new moved item just as in the OOM. Why not just use CopyTo with an RDOMail
item as the target, that gives you a new copied item and then you can do
whatever you want with it, including moving it.




Thank you Ken for the hint with the GUID. I tryed it and it seems to
work very good.

Thank you Dmitry for the Redemption.dll which is a great and very
helpful utility.

At least one more question: If I try to copy an item with an added
property from a write protected folder an error occurs (something like
"access problem"). The code to copy an item is this:

If Not objRDOItem Is Nothing Then Call
objRDOItem.CopyTo(objRDOFolder2)

In Outlook you can set a reference to a moved item e. g. Set objItem =
objItem.move(objFolder)

I tryed this for the RDOItem too, but this does not work: If Not
objRDOItem Is Nothing Then Set objRDOItem =
objRDOItem.CopyTo(objRDOFolder2)

Is there another method to get the reference of the copied item? If
so, I could add the property after I copied the item. If it is not
possible I would copy it to a temp folder, add the property and then
move it to the destination folder. But this is not very comfortable.

Peter
 
Thanks, Ken, that was a very good idea. I didn`t know that it`s
possible to create a new message in the destination folder and then
copy the source item to it.

Thanks to all which spent their time to answer my and ohters
questions!

Peter
 
Back
Top