Assigning Properties to a Folder

R

Rob

I have created a new folder to store copies of emails sent programmatically
via an Access application. In this new folder I have added a column, which I
want to store an easily identifiable name for sorting purposes. In my Access
VBA code, how do I reference the specific column of this new folder and
assign it a value so that it displays when the sent email is listed?

Thanks
 
R

Rob

Here's a sample of my code. I have to use Outlook REdemption, to handle the
security issues. Where would your reccommendation fit in? And thank you for
responding to my question.

Set rMail = New Redemption.SafeMailItem
'Set oItem = Application.CreateItem(0)
Set oItem = myApp.CreateItem(olMailItem)
Set Utils = CreateObject("Redemption.MAPIUtils")
Set NS = myApp.GetNamespace("MAPI")
NS.Logon
Set Sync = NS.SyncObjects.Item(1)
Set oSent = NS.GetDefaultFolder(olFolderSentMail)
'Set oSentFolder = oSent.Parent.Folders("Emailed Offers")
'Set oSent = NS.GetDefaultFolder(olFolderSentMail)
oSent.Folders ("Emailed Offers")
'oSent.Folders("Emailed Offers").UserProperties("Sent To") = "ME"
oItem.UserProperties("Sent To") = "ME"
'MailItem.UserProperties("ColumnName").


rMail.Item = oItem
 
M

Michael Bauer [MVP - Outlook]

Set oItem = myApp.CreateItem(olMailItem)
oItem.UserProperties("Sent To") = "ME"

If the property exists for sure, that's it:

Set oItem = myApp.CreateItem(olMailItem)
oItem.UserProperties("Sent To").Value = "ME"
oItem.Save


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


Am Wed, 16 May 2007 19:56:02 -0700 schrieb Rob:
 
R

Rob

When I have my code as you show:

Set oItem = myApp.CreateItem(olMailItem)
oItem.UserProperties("Sent To").Value = "ME"
oItem.Save

I get the following error where I am setting the "Sent To" Value:
Object variable or With block variable not set

I have created the column in the created folder, yet I reference this new
folder in the oSent object (as shown in my previously posted code snippet).
Should I reference the oSent object instead of the oItem? How, after I just
created the oItem, will it know that I want to 'Sent To' column. Also, the
whole intention of this is that when an email is copied to this folder,
instead of showing only an email address, it will also show an easily
recognizable name so that the user can organize their sent emails for this
folder easier.
 
M

Michael Bauer [MVP - Outlook]

The error means that the property doesn't exist on that item. This is what
I'd do:

Dim Prop as Outlook.UserProperty

Set Prop=GetProperty(oItem.UserProperties, "Sent To")
If not Prop is nothing then
Prop.Value="ME"
Endif



private function GetProperty(Properties as Outlook.UserProperties, Name as
string) as Outlook.UserProperty
On Error Resume Next
Dim Prop as Outlook.UserProperty

Set Prop=Properties(Name)
If Prop is Nothing Then
Set Prop=Properties.Add(Name)
Endif
Set GetProperty=Prop
End Function

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


Am Thu, 17 May 2007 16:39:12 -0700 schrieb Rob:
 
Top