Creating a MSG using MsgKit - how to use AddProperty-method?

141 Views Asked by At

I am using this tool https://github.com/Sicos1977/MsgKit to create a MSG-file, then display and send it with Outlook.

I need to add the property "BillingInformation", so that after sending, an OutlookAddin is able to process the information.

I know, there is a method "AddProperty" - but i am not able to do this properly.

Can anyone help me? THX!

        using (var email = new Email( 
            new Sender(SenderTextBox.Text, string.Empty),
            SubjectTextBox.Text, 
            DraftMessageCheckBox.Checked,
            ReadReceiptCheckBox.Checked)) 
        {
            email.Recipients.AddTo(ToTextBox.Text);
            email.Subject = SubjectTextBox.Text;
            email.BodyText = TextBodyTextBox.Text;
            email.Attachments.Add("Images\\peterpan.jpg");

            email.AddProperty(??????, "abcd");
  
            email.Save("c:\\temp\\email.msg");
                     }
  
        System.Diagnostics.Process.Start("c:\\temp\\email.msg");
2

There are 2 best solutions below

8
On

I don't use MsgKit, but looking at its source code, what you need is something like the following

var billingPropTag = new NamedPropertyTag(0x8535, "Billing", 
                          new Guid("00062008-0000-0000-C000-000000000046"),
                          PropertyType.UNICODE)
email.AddProperty(billingPropTag , "abcd");

You can see property tags (named and fixed) with the their tags, GUIDs and ids using OutlookSpy (I am its author) if you click IMessage button or open an MSG file by clicking OpenIMsgOnIStg:

enter image description here

0
On

I just released a new MSGKit package. I never realised that this was a named property not a normal one.

enter image description here