How to add custom user properties in MailMessage or MSG file using Aspose.Network

Hi All,

I have to add custom user propery in MailMessage or MSG file and same I want to extract it when Outlook fires SendItem event i. e

//Code to create mail message and add custom user property.

AsposeLib.MailMessage msg = new Aspose.Network.Mail.MailMessage();

msg.To = new AsposeLib.MailAddress("jsakhiya@cybage.com");

msg.Subject = "hello";

msg.TextBody = "hello";

MapiMessage mapi = MapiMessage.FromMailMessage(msg);

mapi.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);

mapi.Save("c:\\Test1.msg");


//Event from where I want to get custom property.

private void obj_ItemSend(object sender, ref bool arg)

{

Outlook.MailItem mailitem = (Outlook.MailItem)(sender);

//Here i shoud get that custom property which is added in MSG file.

}

How do I do this using aspose.network libraty

Hi,

Thanks for considering Aspose.

I am sorry that we do not support custom outlook properties yet…

Hello,

Thanks for your updates. Actually according to below code I am able to add my own user defined property.

AsposeLib.MailMessage msg = new Aspose.Network.Mail.MailMessage();
msg.To = new AsposeLib.MailAddress("jsakhiya@cybage.com");
msg.Subject = "hello";
msg.TextBody = "hello";
MapiMessage mapi = MapiMessage.FromMailMessage(msg);
MapiProperty mp1 = new MapiProperty("Myprop", 123, 1, StreamFile(@"c:\TempFile.txt"));
mapi.Properties.Add(123, mp1);
mapi.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
mapi.Save("c:\\Test1.msg");

Here, before saving message, if I evaluate property ‘mapi.Properties’ then I can get my own defined property. But after saving this message to the physical location, when I re-open particular item, I am unable to find it.

It would be great help if you can provide any help on how to persist user defined properties.

Thanks,

Jagdish.