Sicos1977 / MsgKit

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

create Contact .msg #82

Closed ProxBiz closed 2 years ago

ProxBiz commented 3 years ago

Hello, Any chance of implementing or a hint on how to create a Contact .msg file with this library. Wanted to extend it myself but having problems. Regards

Sicos1977 commented 3 years ago

Do you have an example file so that I can have a look inside? Making a contact file is nothing more than figuring out the properties that are needed and implement these in a new contact class.

ProxBiz commented 3 years ago

In my trials I have kind of made a contact. I could read the content with MSTReader from your other repository but when double clicking and opening with outlook I receive a Could not read Item warning. Tried putting together some things from the MSGReader and look at the FileStream but I couldn`t convert to something that I understand. I have attached a contact with all the properties from outlook as .msg and .msg unicode. Thank you for the response and help.

contact.zip

ProxBiz commented 3 years ago

Any updates or some documentation you can refer me so I can try it myself ? Regards

Sicos1977 commented 3 years ago

Sorry about the late response (to busy with work).

What I would do is;

image

#region WriteToStorage
        /// <summary>
        ///     Writes all the properties that are part of the <see cref="Appointment"/> object either as <see cref="CFStorage"/>'s
        ///     or <see cref="CFStream"/>'s to the <see cref="CompoundFile.RootStorage"/>
        /// </summary>
        private new void WriteToStorage()
        {
            Class = MessageClass.IPM_Appointment;
            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);
        }
        #endregion

Create the MSG file and see If Outlook wants to open it without errors

Sicos1977 commented 3 years ago

I already made a start with the Contact class (59558fc6c4139104be8c91418a132e4baa5bb018) to show you how it is done. If you need any help then just post a question in this issue.

It is not difficult to make, it is just hard to figure out what properties are needed and how to map them.

ProxBiz commented 3 years ago

Thank you for the replay, will give it a shot tomorrow.

Sicos1977 commented 3 years ago

@ProxBiz : You can stop your own effort (if you even started :-) ) I'm about 80 procent done with implementing the contact card. With some luck it will be finished next week.

https://github.com/Sicos1977/MsgKit/commit/27bcd571adaba103196bb02595035b1a791a7240

ProxBiz commented 3 years ago

Haha, thanks for the heads up, i was 30% in the process. Wanted to follow your good coding practice so i can branch and merge my changes. I will be following the next updates. Thanks and have a great weekend.

Sicos1977 commented 3 years ago

Thank you for the coding practice complement. Always try to keep it as decently as possible. I also work in projects with more then a million lines of code and then it is always nice if you have good structured code that is easy to read.

Sicos1977 commented 3 years ago

All the properties are added, now it will be testing test and testing to make everything work and keep Outlook happy. Feel free to test.

ProxBiz commented 3 years ago

looks good on my end, can you post new nugget package ?

Sicos1977 commented 3 years ago

Not now because everything is not working as it should, that needs to be fixed first.

Sicos1977 commented 3 years ago

I hope to finish the contact option this week, work was to busy to do anything last week.

ProxBiz commented 3 years ago

No problem, i understand you have other things to do. Take your time