View Single Post
  #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 -



Ads