Quantcast
Channel: Aspose.Email Product Family
Viewing all articles
Browse latest Browse all 1367

Unable to set some of the recipient properties in PST file

$
0
0
Hi, I am unable to set a number of properties on a MapiRecipient object in a newly created PST file.

They seem to disappear from properties collection after message gets added to any folder inside PST file.

Here is example of my test code:
public static void Main()
{
    File.Delete("c:\\storage.pst");
    using (PersonalStorage storage = PersonalStorage.Create("c:\\storage.pst", FileFormatVersion.Unicode))
    using (MapiMessage message = new MapiMessage())
    {
        AddRecipient(message);
        PrintRecipientProperties(message, "Before FolderInfo.AddMessage:");
        storage.RootFolder.AddMessage(message);
        PrintRecipientProperties(storage.RootFolder.EnumerateMapiMessages().First(), "After FolderInfo.AddMessage:");
    }
    using (PersonalStorage storage = PersonalStorage.FromFile("c:\\storage.pst"))
    {
        PrintRecipientProperties(storage.RootFolder.EnumerateMapiMessages().First(), "After PersonalStorage.FromFile:");
    }
}

private static void AddRecipient(MapiMessage message)
{
    message.Recipients.Add("TestUser1", string.Empty, MapiRecipientType.MAPI_TO);
    MapiRecipient recipient = message.Recipients[0];
    recipient.SetProperty(new MapiProperty(MapiPropertyTag.PR_RECIPIENT_TRACKSTATUS, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x39050003 /*PR_DISPLAY_TYPE_EX*/, BitConverter.GetBytes((long) 1073741824)));
    recipient.SetProperty(new MapiProperty(0x5FF6001F /*PR_RECIPIENT_DISPLAY_NAME_W*/, Encoding.Unicode.GetBytes("TestUser1")));
    recipient.SetProperty(new MapiProperty(0x5FFD0003 /*PR_RECIPIENT_FLAGS*/, BitConverter.GetBytes((long) 1)));
    recipient.SetProperty(new MapiProperty(0x5FDF0003 /*PR_RECIPIENT_ORDER*/, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x5FDE0003 /*PR_RECIPIENT_RESOURCE_STATE*/, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(MapiPropertyTag.PR_SEND_INTERNET_ENCODING, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x39FE001F /*PR_SMTP_ADDRESS*/, Encoding.Unicode.GetBytes("TestUser1@test.com")));
    recipient.SetProperty(new MapiProperty(MapiPropertyTag.PR_TRANSMITABLE_DISPLAY_NAME_W, Encoding.Unicode.GetBytes("TestUser1")));
    recipient.SetProperty(new MapiProperty(MapiPropertyTag.PR_AB_PROVIDERS, new byte[] {0xB4, 0x7C, 0x0B, 0xFC, 0xCE, 0x06, 0xA7, 0x40, 0x97, 0x0C, 0xB0, 0x51, 0x33, 0x79, 0x04, 0xDB}));
    recipient.SetProperty(new MapiProperty(0x5FEB0003 /*PR_RECIPIENT_TRACKSTATUS_RECALL*/, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x5FEF0003 /*PR_RECIPIENT_TRACKSTATUS_RESPONSE*/, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x5FF20003 /*PR_RECIPIENT_TRACKSTATUS_READ*/, BitConverter.GetBytes((long) 0)));
    recipient.SetProperty(new MapiProperty(0x5FF50003 /*PR_RECIPIENT_TRACKSTATUS_DELIVERY*/, BitConverter.GetBytes((long) 0)));
}

private static void PrintRecipientProperties(MapiMessage message, string description)
{
    Console.WriteLine(Environment.NewLine + description);
    Console.WriteLine("PR_RECIPIENT_TRACKSTATUS: " + message.Recipients[0].Properties[MapiPropertyTag.PR_RECIPIENT_TRACKSTATUS]);
    Console.WriteLine("PR_DISPLAY_TYPE_EX: " + message.Recipients[0].Properties[0x39050003]);
    Console.WriteLine("PR_RECIPIENT_DISPLAY_NAME_W: " + message.Recipients[0].Properties[0x5FF6001F]);
    Console.WriteLine("PR_RECIPIENT_FLAGS: " + message.Recipients[0].Properties[0x5FFD0003]);
    Console.WriteLine("PR_RECIPIENT_ORDER: " + message.Recipients[0].Properties[0x5FDF0003]);
    Console.WriteLine("PR_RECIPIENT_RESOURCE_STATE: " + message.Recipients[0].Properties[0x5FDE0003]);
    Console.WriteLine("PR_SEND_INTERNET_ENCODING: " + message.Recipients[0].Properties[MapiPropertyTag.PR_SEND_INTERNET_ENCODING]);
    Console.WriteLine("PR_SMTP_ADDRESS: " + message.Recipients[0].Properties[0x39FE001F]);
    Console.WriteLine("PR_TRANSMITABLE_DISPLAY_NAME_W: " + message.Recipients[0].Properties[MapiPropertyTag.PR_TRANSMITABLE_DISPLAY_NAME_W]);
    Console.WriteLine("PR_AB_PROVIDERS: " + message.Recipients[0].Properties[MapiPropertyTag.PR_AB_PROVIDERS]);
    Console.WriteLine("PR_RECIPIENT_TRACKSTATUS_RECALL: " + message.Recipients[0].Properties[0x5FEB0003]);
    Console.WriteLine("PR_RECIPIENT_TRACKSTATUS_RESPONSE: " + message.Recipients[0].Properties[0x5FEF0003]);
    Console.WriteLine("PR_RECIPIENT_TRACKSTATUS_READ: " + message.Recipients[0].Properties[0x5FF20003]);
    Console.WriteLine("PR_RECIPIENT_TRACKSTATUS_DELIVERY: " + message.Recipients[0].Properties[0x5FF50003]);
}

Output example:
Before FolderInfo.AddMessage:
PR_RECIPIENT_TRACKSTATUS: 0
PR_DISPLAY_TYPE_EX: 1073741824
PR_RECIPIENT_DISPLAY_NAME_W: TestUser1
PR_RECIPIENT_FLAGS: 1
PR_RECIPIENT_ORDER: 0
PR_RECIPIENT_RESOURCE_STATE: 0
PR_SEND_INTERNET_ENCODING: 0
PR_SMTP_ADDRESS: TestUser1@test.com
PR_TRANSMITABLE_DISPLAY_NAME_W: TestUser1
PR_AB_PROVIDERS: B47C0BFCCE06A740970CB051337904DB
PR_RECIPIENT_TRACKSTATUS_RECALL: 0
PR_RECIPIENT_TRACKSTATUS_RESPONSE: 0
PR_RECIPIENT_TRACKSTATUS_READ: 0
PR_RECIPIENT_TRACKSTATUS_DELIVERY: 0

After FolderInfo.AddMessage:
PR_RECIPIENT_TRACKSTATUS:
PR_DISPLAY_TYPE_EX:
PR_RECIPIENT_DISPLAY_NAME_W:
PR_RECIPIENT_FLAGS:
PR_RECIPIENT_ORDER:
PR_RECIPIENT_RESOURCE_STATE:
PR_SEND_INTERNET_ENCODING:
PR_SMTP_ADDRESS:
PR_TRANSMITABLE_DISPLAY_NAME_W:
PR_AB_PROVIDERS:
PR_RECIPIENT_TRACKSTATUS_RECALL:
PR_RECIPIENT_TRACKSTATUS_RESPONSE:
PR_RECIPIENT_TRACKSTATUS_READ:
PR_RECIPIENT_TRACKSTATUS_DELIVERY:

After PersonalStorage.FromFile:
PR_RECIPIENT_TRACKSTATUS:
PR_DISPLAY_TYPE_EX:
PR_RECIPIENT_DISPLAY_NAME_W:
PR_RECIPIENT_FLAGS:
PR_RECIPIENT_ORDER:
PR_RECIPIENT_RESOURCE_STATE:
PR_SEND_INTERNET_ENCODING:
PR_SMTP_ADDRESS:
PR_TRANSMITABLE_DISPLAY_NAME_W:
PR_AB_PROVIDERS:
PR_RECIPIENT_TRACKSTATUS_RECALL:
PR_RECIPIENT_TRACKSTATUS_RESPONSE:
PR_RECIPIENT_TRACKSTATUS_READ:
PR_RECIPIENT_TRACKSTATUS_DELIVERY:

The most important property for me right now is PR_SMTP_ADDRESS (0x39FE001F). Because it is not set in a resulting file, user that opens my PST file, can't respond to any messages inside of it (please see attached images that show difference between PST files created by Aspose and Outlook)

Viewing all articles
Browse latest Browse all 1367

Trending Articles