我从兑换网站采用了此代码:http://www.dimastr.com/redemption/objects.htm
Function IsOneOffEntryID(EntryID)
'check the first 20 bytes
OOEID = Array(0,0,0,0,&H81,&H2B,&H1F,&HA4,&HBE,&HA3,&H10,&H19,&H9D,&H6E,0,&HDD,&H01,&H0F,&H54,&H02)
IsOneOffEntryID = true
for i = 0 to 19
if EntryID(i) <> OOEID(i) Then
IsOneOffEntryID = false
Exit Function
End If
Next
End Function
PR_ENTRYID = &HFFF0102
PR_SEND_RICH_INFO = &H3A40000B
set sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = MailItem
For i = 1 to sItem.Recipients.Count
entryBytes = sItem.Recipients.Item(i).Fields(PR_ENTRYID)
If IsOneOffEntryID(entryBytes) Then
entryBytes(22) = 1
sItem.Recipients.Item(i).Fields(PR_ENTRYID) = entryBytes
sItem.Recipients.Item(i).Fields(PR_SEND_RICH_INFO) = false
MailItem.Subject = MailItem.Subject ' just to make Outlook think something has changed
MailItem.Save
End If
Next
并在c#中重新编码:
private static bool IsOneOffEntryID(object[] EntryID)
{
byte[] OOEID = new byte[]
{
0, 0, 0, 0, 0x81, 0x2B, 0x1F, 0xA4, 0xBE, 0xA3, 0x10, 0x19, 0x9D, 0x6E, 0, 0xDD, 0x01, 0x0F, 0x54,
0x02
};
bool IsOneOffEntryID = true;
for (int i = 0; i < 20; i++)
{
if ((byte)EntryID[i] != OOEID[i])
{
IsOneOffEntryID = false;
break;
}
}
return IsOneOffEntryID;
}
public static void ForcePlain(Outlook.MailItem item)
{
Log.Debug("ForcePlain entry");
int PR_ENTRYID = 0xFFF0102;
int PR_SEND_RICH_INFO = 0x3A40000B;
SafeMailItem smailItem = RedemptionLoader.new_SafeMailItem();
SafeRecipients recpts = null;
SafeRecipient recpt = null;
smailItem.Item = item;
recpts = smailItem.Recipients;
for (int i = 1; i <= recpts.Count; i++)
{
recpt = recpts[i];
object[] entryBytes = recpt.Fields[PR_ENTRYID] as object[];
if (IsOneOffEntryID(entryBytes))
{
entryBytes[22] = 1;
recpt.Fields[PR_ENTRYID] = entryBytes;
Log.Debug("Just before setting flag ...");
recpt.Fields[PR_SEND_RICH_INFO] = 0;
item.Subject = item.Subject;
item.Save();
}
Marshal.ReleaseComObject(recpt);
recpt = null;
}
if (smailItem != null)
{
Marshal.ReleaseComObject(smailItem);
smailItem = null;
}
if (recpts != null)
{
Marshal.ReleaseComObject(recpts);
recpts = null;
}
Log.Debug("ForcePlain exit");
}
大部分时间都有效。但请致电:
recpt.Fields[PR_SEND_RICH_INFO] = 0;
正在崩溃前景,但仅限于某些收件人。正如我在大多数情况下所说,它有效,但我们有2台测试计算机有这个问题。
其他计算机可以成功发送给在这两台计算机上崩溃Outlook的相同收件人,因此我怀疑它与他们的地址条目有关。
非常糟糕的情况,因为它不会抛出我可以处理的异常,但它只会导致前景崩溃。
谢谢, Velja
答案 0 :(得分:0)
&#34;崩溃&#34;如在&#34;未处理的访问违规&#34;?或COM错误?
请注意,PR_SEND_RICH_INFO是布尔属性,而不是int:
recpt.Fields[PR_SEND_RICH_INFO] = false;