English 中文(简体)
公开分享的前景 项目损失 用户特性
原标题:Outlook OpenSharedItem lose User properties

I m试图储存用户特性中的一些数据,然后将邮件发至.msg文档,(later/em>)将文件上载至用户财产。

问题在于:在重载档案后,我没有任何用户财产。

Im 采用《2010年展望》32 轨道

这里是一部体现以下行为的法典:

Outlook.MailItem originalItem = ((MailItemWrapper)this.Item)._item;

var path = System.IO.Path.GetTempFileName() + ".msg";
var propName = "ActionId123456789";

// Set a user property "ActionId" with value "test"
var ps = originalItem.UserProperties;
var p = ps.Find(propName);
if (p == null)
    p = ps.Add(propName, Outlook.OlUserPropertyType.olText, Type.Missing);
p.Value = "test";

// Save to a temp file
originalItem.Save(); // --> I also tried without this line
originalItem.SaveAs(path);

// Chech the the property is correctly set
p = originalItem.UserProperties[propName];
if (p != null)
    Console.WriteLine(p.Value); // ---> Show  test 

// Open the temp file
Outlook.MailItem newItem = AddinModule.CurrentInstance.OutlookApp.Session.OpenSharedItem(path) as Outlook.MailItem;

// Check that the property still exists
p = newItem.UserProperties[propName];
if (p != null)
    Console.WriteLine(p.Value); // ---> Not executed: p is NULL !

是否有人知道如何这样做?

Instead of using OpenSharedItem, I also tried opening the mail using Process.Start, but in this case the user property is also null ...

BTW 这份法典是一个测试样本,因此它有t dispose,所有COM参考文献都正确无误。

最佳回答
问题回答

这个论坛职位确切描述了你的问题——User Property are not persistent in MSG。 我也经历过同样的行为,即:,由微软公司在2007年上改动。

作为工作,我刚刚使用了。 光盘()与用户特性储存我的<密码>。

如果这种工作方式对你来说是一种可能性,你可能需要与ESWS合作,将其储存在一份共用的邮箱上,并使用能够代替MSG出口到软盘的用户财产。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...