+2 votes

We liked your product and currently We have done some experiment and check all functions.

Now we want to know how can I read appointment through this class Limilabs.Client.IMAP.MessageInfo.

we have prefer this class to download mails because it is fast so, I have attach appointment but I cant find it in this mentioned class.

or, can we search Appointment related mails through IMAP search. if so then what kind of expression we need.

could you please suggest the way to do.

by

1 Answer

0 votes
 
Best answer

Appointment emails are regular emails that have ical (*.ics) appointment added as a attachment or alternative email view.

It is not possible to read such appointment through MessageInfo class. This is because it is used to download most common email information only. It doesn't download any attachment data - this is the reason why Imap.GetMessageInfoByUID is so fast.

What you should do is to iterate through MessageInfo.Envelope.Attachments collection and find MimeStructure that has ContentType property set to ContentType.ApplicationIcs or ContentType.TextCalendar. This object represents attached appointment invitation.

You can use Imap.GetDataByUID to download actual appointment data and then AppointmentParser class to parse it.

MessageInfo info = imap.GetMessageInfoByUID(uid);

MimeTextStructure structure = 
    (MimeTextStructure) info.BodyStructure.Attachments.Find(
        x=>x.ContentType == ContentType.ApplicationIcs
        || x.ContentType == ContentType.TextCalendar);

imap.GetDataByUID(structure); 

Appointment appointment = new AppointmentParser().Parse(structure.Text);

Assert.AreEqual("Meeting at 9", appointment.Event.Summary);

can we search Appointment related mails through IMAP search.
I don't think this is possible. Maybe using Gmail search extensions, unfortunately regular IMAP search doesn't have any attachment related search expressions.

Please note that this is a limitation of IMAP protocol not the Mail.dll.

Still if you have MessageInfo objects you can use above method to find messages which contain ical appointments.

by (301k points)
...