Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Access MaiItem.UserProperties using Redemption (http://www.outlookbanter.com/outlook-vba/61718-access-maiitem-userproperties-using-redemption.html)

MA[_2_] November 22nd 07 05:00 AM

Access MaiItem.UserProperties using Redemption
 
Hi,

I am using the Redemption to create a message. I need to add the user
defined fields to the message.

I know the Outlook.MaiItem has the UserProperties which allow to add
field and optionally attach to the folder. However, UserProperties not
available in Redemption.

How can I access the UserProperties from the RDOMail?

--------------------------------------------
// Get the RDOFolder
session.MAPIOBJECT = olApp.Session.MAPIOBJECT;
RDOFolder rdoFolder = session.GetFolderFromPath(@"\\Bob Builder
\Inbox");

// Create the message
RDOMail msg = rdoFolder.Items.Add("IPM.Note.CRM");
msg.Sent = true;
msg.Subject = String.Format("Test sent message: {0}", DateTime.Now);
RDORecipient recipient = ");
recipient.Resolve(false, null);
msg.Sender = session.CurrentUser;
msg.SentOn = Convert.ToDateTime("2007/09/10",
System.Globalization.CultureInfo.CurrentCulture);
msg.Body = "Test message body";
msg.Save();
---------------------------------------------

Thanks for looking at the issue.

Regards,
MA

Dmitry Streblechenko November 22nd 07 10:00 PM

Access MaiItem.UserProperties using Redemption
 
Set the properties using RDOMail.Fields - see
http://www.dimastr.com/redemption/rd...htm#properties

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

"MA" wrote in message
...
Hi,

I am using the Redemption to create a message. I need to add the user
defined fields to the message.

I know the Outlook.MaiItem has the UserProperties which allow to add
field and optionally attach to the folder. However, UserProperties not
available in Redemption.

How can I access the UserProperties from the RDOMail?

--------------------------------------------
// Get the RDOFolder
session.MAPIOBJECT = olApp.Session.MAPIOBJECT;
RDOFolder rdoFolder = session.GetFolderFromPath(@"\\Bob Builder
\Inbox");

// Create the message
RDOMail msg = rdoFolder.Items.Add("IPM.Note.CRM");
msg.Sent = true;
msg.Subject = String.Format("Test sent message: {0}", DateTime.Now);
RDORecipient recipient = ");
recipient.Resolve(false, null);
msg.Sender = session.CurrentUser;
msg.SentOn = Convert.ToDateTime("2007/09/10",
System.Globalization.CultureInfo.CurrentCulture);
msg.Body = "Test message body";
msg.Save();
---------------------------------------------

Thanks for looking at the issue.

Regards,
MA




MA[_2_] November 23rd 07 12:07 AM

Access MaiItem.UserProperties using Redemption
 
Thanks Dmitry for your answer.

The RDOMail does not seems to have the "Fields" property. I can see
the set_Fields, get_Fields, GetPropList, etc. Am I missing something
in here?

Thanks in advance for your suggestions.

Regards,
MA

MA[_2_] November 23rd 07 12:15 AM

Access MaiItem.UserProperties using Redemption
 
Basically, I want to add the add the fields to the message. I can do
this using the Outlook MailItem. I am not sure how to use it when
using the Redemption.RDOMail item. Should I need to access the Outlook
MailItem after I create the message using the RDOMail (see the source
code above).

Could you please provide some example.

Example below which uses the Outlook.MailItem:
quote
Outlook.MailItem msg = folder.Items.Add("IPM.Note") as MailItem;
msg.UserProperties.Add("Test Field",
Outlook.OlUserPropertyType.olText, true, "")
/quote


Thanks,
MA

Dmitry Streblechenko November 23rd 07 08:02 AM

Access MaiItem.UserProperties using Redemption
 
set_Fields/get_Fields are the getter/setter for the Fields indexed property:

RDOMail.set_Fields("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/PropertyName",
"some new value");
RDOMail.Save;

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

"MA" wrote in message
...
Thanks Dmitry for your answer.

The RDOMail does not seems to have the "Fields" property. I can see
the set_Fields, get_Fields, GetPropList, etc. Am I missing something
in here?

Thanks in advance for your suggestions.

Regards,
MA




MA[_2_] November 28th 07 05:30 AM

Access MaiItem.UserProperties using Redemption
 
Thanks for your suggestions.

I have tried the following code which did not add the custom field.
-------------------------------------------------------
rdoMsg.set_Fields("http://schemas.microsoft.com/mapi/string/
{00063034-0000-0000-C000-000000000046}/UDF1", "test value");
rdoMsg.Save();
-------------------------------------------------------

However, I can add the custom field using the code below:

-------------------------------------------------------
rdoMsg.HTMLBody = "test STRONGmessage/STRONG body.";
rdoMsg.Save();

Outlook.MailItem olMsg =
(Outlook.MailItem)olNameSpace.GetItemFromID(rdoMsg .EntryID, "");
Outlook.UserProperty udf = olMsg.UserProperties.Add("UDF1",
Outlook.OlUserPropertyType.olText, false, false);
olMsg.UserProperties["UDF1"].Value = "Some value";
olMsg.Save();
-------------------------------------------------------

Am I missing something?

Thanks,
MA

Dmitry Streblechenko November 28th 07 06:41 PM

Access MaiItem.UserProperties using Redemption
 
Where and when are you using the added user property? Can you see it in
OutlookSpy when you click IMessage?
The values of the user properties are stored as regular named MAPI
properties (that is what rdoMsg.set_Fields will do for you).
Outlook however (when you use MailItem.UserProperties.Add) also adds the
property *definition* to a special blob (you can also see it in OutlookSpy).
If the property defintiion is not added (Redemption does not do that),
MailItem.UserProperties collection won't see it even if the value is there.

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

"MA" wrote in message
...
Thanks for your suggestions.

I have tried the following code which did not add the custom field.
-------------------------------------------------------
rdoMsg.set_Fields("http://schemas.microsoft.com/mapi/string/
{00063034-0000-0000-C000-000000000046}/UDF1", "test value");
rdoMsg.Save();
-------------------------------------------------------

However, I can add the custom field using the code below:

-------------------------------------------------------
rdoMsg.HTMLBody = "test STRONGmessage/STRONG body.";
rdoMsg.Save();

Outlook.MailItem olMsg =
(Outlook.MailItem)olNameSpace.GetItemFromID(rdoMsg .EntryID, "");
Outlook.UserProperty udf = olMsg.UserProperties.Add("UDF1",
Outlook.OlUserPropertyType.olText, false, false);
olMsg.UserProperties["UDF1"].Value = "Some value";
olMsg.Save();
-------------------------------------------------------

Am I missing something?

Thanks,
MA




MA[_2_] November 29th 07 12:25 AM

Access MaiItem.UserProperties using Redemption
 
Thanks for the clarification.

It make sense now and I can see the property when I use the IMessage
(Love the OutlookSpy).

I need to locate the fields using the Outlook client. In this case,
the fields need to be added to the folder definitions. The following
code works fine.
-----------------------------------------------------
Outlook.MailItem olMsg =
(Outlook.MailItem)olNameSpace.GetItemFromID(rdoMsg .EntryID, "");
Outlook.UserProperty udf = olMsg.UserProperties.Add("UDF4",
Outlook.OlUserPropertyType.olText, true,
Outlook.OlUserPropertyType.olText);
olMsg.UserProperties["UDF4"].Value = "Test value";
olMsg.Save();
-----------------------------------------------------

Any suggestions.

Thanks,
MA


Dmitry Streblechenko November 29th 07 05:54 AM

Access MaiItem.UserProperties using Redemption
 
You can add a field to folder fields (so it will be visible in the field
picker) without creating a message - use RDOFolder2.FolderFields:
http://www.dimastr.com/redemption/rd...htm#rdofolder2

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

"MA" wrote in message
...
Thanks for the clarification.

It make sense now and I can see the property when I use the IMessage
(Love the OutlookSpy).

I need to locate the fields using the Outlook client. In this case,
the fields need to be added to the folder definitions. The following
code works fine.
-----------------------------------------------------
Outlook.MailItem olMsg =
(Outlook.MailItem)olNameSpace.GetItemFromID(rdoMsg .EntryID, "");
Outlook.UserProperty udf = olMsg.UserProperties.Add("UDF4",
Outlook.OlUserPropertyType.olText, true,
Outlook.OlUserPropertyType.olText);
olMsg.UserProperties["UDF4"].Value = "Test value";
olMsg.Save();
-----------------------------------------------------

Any suggestions.

Thanks,
MA




MA[_2_] December 12th 07 04:53 AM

Access MaiItem.UserProperties using Redemption
 
Thanks.

I have tried the following code without any success. The
RDOFolderField - "field" object return null. I have tried without GUID
by passing null value. String.empty on Guid return exception. Any
suggestions?

------------------------------------
RDOFolder2 rdoFolder2 = (RDOFolder2)rdoFolder;
RDOFolderField field = rdoFolder2.FolderFields.Add("UDF2",
Redemption.rdoUserPropertyType.olText, "{00020329-0000-0000-
C000-000000000046}", 0);

if (field != null)
rdoFolder2.FolderFields.Save();
---------------------------------

Regards,
MA


All times are GMT +1. The time now is 03:36 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-2006 OutlookBanter.com