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

How to add an userpropertie to an email folder?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 2nd 07, 03:15 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default How to add an userpropertie to an email folder?

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

Ads
  #2  
Old September 3rd 07, 06:29 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default How to add an userpropertie to an email folder?



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

  #3  
Old September 3rd 07, 07:38 AM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default How to add an userpropertie to an email folder?

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]"
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- Zitierten Text ausblenden -


- Zitierten Text anzeigen -



  #4  
Old September 3rd 07, 11:24 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to add an userpropertie to an email folder?

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" wrote in message
oups.com...
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]"
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- Zitierten Text ausblenden -


- Zitierten Text anzeigen -




  #5  
Old September 4th 07, 08:42 AM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default How to add an userpropertie to an email folder?

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

On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:
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" wrote in message

oups.com...
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]"
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-Zitierten Text ausblenden -


- Zitierten Text anzeigen -- Zitierten Text ausblenden -


- Zitierten Text anzeigen -



  #6  
Old September 4th 07, 05:41 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to add an userpropertie to an email folder?

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

"Peter Marchert" wrote in message ups.com...
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

On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:
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" wrote in message

oups.com...
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]"
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-Zitierten Text ausblenden -


- Zitierten Text anzeigen -- Zitierten Text ausblenden -


- Zitierten Text anzeigen -



  #7  
Old September 4th 07, 06:05 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default How to add an userpropertie to an email folder?

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

On 4 Sep., 18:41, "Dmitry Streblechenko" wrote:
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

"Peter Marchert" wrote in oglegroups.com...

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

On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:



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" wrote in message


roups.com...
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]"
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 -



  #8  
Old September 4th 07, 07:15 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to add an userpropertie to an email folder?

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("t est")
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

"Peter Marchert" wrote in message
ups.com...
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

On 4 Sep., 18:41, "Dmitry Streblechenko" wrote:
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

"Peter Marchert" wrote in
oglegroups.com...

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

On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:



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" wrote in message


roups.com...
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]"
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 -




  #9  
Old September 4th 07, 08:48 PM posted to microsoft.public.outlook.program_vba
Peter Marchert
external usenet poster
 
Posts: 116
Default How to add an userpropertie to an email folder?

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

Sub TestUserProperty()

Dim strFilter As String

strFilter = "[MyTestProperty] """""

Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restric t(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


On 4 Sep., 20:15, "Dmitry Streblechenko" wrote:
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("t est")
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

"Peter Marchert" wrote in message

ups.com...
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

On 4 Sep., 18:41, "Dmitry Streblechenko" wrote:



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


"Peter Marchert" wrote in
oglegroups.com...


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


On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:


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" wrote in message


roups.com...
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]"
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 -



  #10  
Old September 4th 07, 11:04 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to add an userpropertie to an email folder?

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" wrote in message
ups.com...
Hmmmm....that is a nice idea, but...

Sub TestUserProperty()

Dim strFilter As String

strFilter = "[MyTestProperty] """""

Debug.Print
Outlook.ActiveExplorer.CurrentFolder.Items.Restric t(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


On 4 Sep., 20:15, "Dmitry Streblechenko" wrote:
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("t est")
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

"Peter Marchert" wrote in message

ups.com...
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

On 4 Sep., 18:41, "Dmitry Streblechenko" wrote:



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


"Peter Marchert" wrote in
oglegroups.com...


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


On 4 Sep., 00:24, "Dmitry Streblechenko" wrote:


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" wrote in message


roups.com...
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]"
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 -




 




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
What gets an email caught by Junk email folder - default settings? JM Outlook - General Queries 3 May 15th 07 08:53 PM
2 simple macros - create task from email and move email to folder [email protected] Outlook and VBA 5 February 4th 07 09:57 AM
Public Folder/Folder Assistant Forwarding email w/o original sender name xtremluck Outlook - General Queries 2 December 20th 06 08:57 PM
Copy email from local folder to public folder Andrew Outlook and VBA 0 November 16th 06 09:29 AM
activate contact folder from public folder with "show this folder as email address book using a prf file Frankie K. Outlook - Using Contacts 7 July 25th 06 05:37 PM


All times are GMT +1. The time now is 06:13 AM.


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.