Sicos1977 / MsgKit

A .NET library to make MSG files without the need for Outlook
204 stars 56 forks source link

RTFCompressed support #18

Closed seeker25 closed 7 years ago

seeker25 commented 7 years ago

Added in support for BodyRtf, RTFCompressed. Included helpers RTFCompressor.cs, Crc32Calculator.cs. Also the spec and documentation with MS-OXRTFCP.

Sicos1977 commented 7 years ago

Thanks, I will merge your code this evening (morning here now in the Netherlands). I will have to resolve some conflicts first.

seeker25 commented 7 years ago

Awesome, tried to make the classes fit the best I could. Hoping to get the contact groups going tomorrow or the next day.

On Sun, Oct 1, 2017 at 11:06 PM, Kees notifications@github.com wrote:

Thanks, I will merge your code this evening (morning here now in the Netherlands)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#issuecomment-333447822, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzXoSa-V3B9PdN_AK0DrOqjcDHoL5ks5soH1PgaJpZM4PqLkc .

Sicos1977 commented 7 years ago

It could be possible that groups use something simular like this --> https://github.com/Sicos1977/MsgKit/blob/master/MsgKit/Structures/UnsendableRecipients.cs

seeker25 commented 7 years ago

I ran the appointment test. Seems to be stuck trying to declare the variable appointment. Location twice.

I looked inside of Appointment.cs

It looks like there has been a repeat of code.

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd);

namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        if (BodyRtfCompressed)
        {

propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED, RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var nps = new NamedProperties(propertiesStream); //Uses the top

level properties. nps.AddProperty(NamedPropertyTags.PidLidLocation, Location); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); nps.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); nps.AddProperty(NamedPropertyTags.PidLidMeetingType, 0x00000001); nps.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, 1);

On Mon, Oct 2, 2017 at 7:12 AM, Kees notifications@github.com wrote:

Merged #18 https://github.com/Sicos1977/MsgKit/pull/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#event-1274102035, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzSNTfmBULXoBoq9moA4cJbHPm8FNks5soO9ogaJpZM4PqLkc .

seeker25 commented 7 years ago

Sorry stuck trying to define a named variable - Location. twice.. It's early haha.

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

I ran the appointment test. Seems to be stuck trying to declare the variable appointment. Location twice.

I looked inside of Appointment.cs

It looks like there has been a repeat of code.

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var nps = new NamedProperties(propertiesStream); //Uses the

top level properties. nps.AddProperty(NamedPropertyTags.PidLidLocation, Location); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); nps.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); nps.AddProperty(NamedPropertyTags.PidLidMeetingType, 0x00000001); nps.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, 1);

On Mon, Oct 2, 2017 at 7:12 AM, Kees notifications@github.com wrote:

Merged #18 https://github.com/Sicos1977/MsgKit/pull/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#event-1274102035, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzSNTfmBULXoBoq9moA4cJbHPm8FNks5soO9ogaJpZM4PqLkc .

seeker25 commented 7 years ago

Should be :

        if (BodyRtfCompressed)
        {

propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED, RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd);

namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay);

namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        namedProperties.WriteProperties(rootStorage);

I think

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

Sorry stuck trying to define a named variable - Location. twice.. It's early haha.

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

I ran the appointment test. Seems to be stuck trying to declare the variable appointment. Location twice.

I looked inside of Appointment.cs

It looks like there has been a repeat of code.

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var nps = new NamedProperties(propertiesStream); //Uses the

top level properties. nps.AddProperty(NamedPropertyTags.PidLidLocation, Location); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); nps.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); nps.AddProperty(NamedPropertyTags.PidLidMeetingType, 0x00000001); nps.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, 1);

On Mon, Oct 2, 2017 at 7:12 AM, Kees notifications@github.com wrote:

Merged #18 https://github.com/Sicos1977/MsgKit/pull/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#event-1274102035, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzSNTfmBULXoBoq9moA4cJbHPm8FNks5soO9ogaJpZM4PqLkc .

seeker25 commented 7 years ago

I think it's the same mechanism UnsendableRecipents uses.. (RecipientRowDisplayType.DistributionList) But it doesn't seem like PidLidAppointmentUnsendableRecipients is actually set in the .msg file.

On Mon, Oct 2, 2017 at 7:53 AM, Travis Semple travis8814@gmail.com wrote:

Should be :

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        namedProperties.WriteProperties(rootStorage);

I think

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

Sorry stuck trying to define a named variable - Location. twice.. It's early haha.

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

I ran the appointment test. Seems to be stuck trying to declare the variable appointment. Location twice.

I looked inside of Appointment.cs

It looks like there has been a repeat of code.

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var nps = new NamedProperties(propertiesStream); //Uses the

top level properties. nps.AddProperty(NamedPropertyTags.PidLidLocation, Location); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); nps.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); nps.AddProperty(NamedPropertyTags.PidLidMeetingType, 0x00000001); nps.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); nps.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, 1);

On Mon, Oct 2, 2017 at 7:12 AM, Kees notifications@github.com wrote:

Merged #18 https://github.com/Sicos1977/MsgKit/pull/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#event-1274102035, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzSNTfmBULXoBoq9moA4cJbHPm8FNks5soO9ogaJpZM4PqLkc .

seeker25 commented 7 years ago

Easy just had to extend the recipients, add in the two properties

        propertiesStream.AddProperty(PropertyTags.PR_OBJECT_TYPE,

ObjectType); propertiesStream.AddProperty(PropertyTags.PR_DISPLAY_TYPE, DisplayType);

On Mon, Oct 2, 2017 at 8:23 AM, Travis Semple travis8814@gmail.com wrote:

I think it's the same mechanism UnsendableRecipents uses.. (RecipientRowDisplayType.DistributionList) But it doesn't seem like PidLidAppointmentUnsendableRecipients is actually set in the .msg file.

On Mon, Oct 2, 2017 at 7:53 AM, Travis Semple travis8814@gmail.com wrote:

Should be :

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(NamedPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(NamedPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(NamedPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        namedProperties.WriteProperties(rootStorage);

I think

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

Sorry stuck trying to define a named variable - Location. twice.. It's early haha.

On Mon, Oct 2, 2017 at 7:52 AM, Travis Semple travis8814@gmail.com wrote:

I ran the appointment test. Seems to be stuck trying to declare the variable appointment. Location twice.

I looked inside of Appointment.cs

It looks like there has been a repeat of code.

        var namedProperties = new NamedProperties(propertiesStream);

//Uses the top level properties. namedProperties.AddProperty(Na medPropertyTags.PidLidLocation, Location); namedProperties.AddProperty(Na medPropertyTags.PidLidAppointmentStartWhole, MeetingStart); namedProperties.AddProperty(Na medPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); namedProperties.AddProperty(Na medPropertyTags.PidLidMeetingType, MeetingType.mtgRequest); namedProperties.AddProperty(Na medPropertyTags.PidLidAppointmentSubType, AllDay); namedProperties.AddProperty(Na medPropertyTags.PidLidAppointmentStateFlags, AppointmentState.asfMeeting);

        if (BodyRtfCompressed)
        {
            propertiesStream.AddProperty(PropertyTags.PR_RTF_COMPRESSED,

RTFCompressor.Compress(Encoding.ASCII.GetBytes(BodyRtf))); propertiesStream.AddProperty(PropertyTags.PR_RTF_IN_SYNC, true); }

        var nps = new NamedProperties(propertiesStream); //Uses

the top level properties. nps.AddProperty(NamedPropertyTags.PidLidLocation, Location); nps.AddProperty(NamedPropertyT ags.PidLidAppointmentStartWhole, MeetingStart); nps.AddProperty(NamedPropertyTags.PidLidAppointmentEndWhole, MeetingEnd); nps.AddProperty(NamedPropertyTags.PidLidMeetingType, 0x00000001); nps.AddProperty(NamedPropertyTags.PidLidAppointmentSubType, AllDay); nps.AddProperty(NamedPropertyT ags.PidLidAppointmentStateFlags, 1);

On Mon, Oct 2, 2017 at 7:12 AM, Kees notifications@github.com wrote:

Merged #18 https://github.com/Sicos1977/MsgKit/pull/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sicos1977/MsgKit/pull/18#event-1274102035, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUpzSNTfmBULXoBoq9moA4cJbHPm8FNks5soO9ogaJpZM4PqLkc .