iCalendar support for email / mime. Compatible with the iCalendar Message-Based Interoperability Protocol (iMIP) RFC 6047.
Add this dependencies your pubspec.yaml file:
dependencies:
enough_mail_icalendar: ^0.2.1
enough_mail: any
enough_icalendar: any
The latest version or enough_mail_icalendar
is .
Check out the full API documentation at https://pub.dev/documentation/enough_mail_icalendar/latest/
Use enough_mail_icalendar
to generate and send MIME email messages for iCalendar requests.
import 'package:enough_icalendar/enough_icalendar.dart';
import 'package:enough_mail/enough_mail.dart';
import 'package:enough_mail_icalendar/enough_mail_icalendar.dart';
With VMessageBuilder.prepareFromCalendar(...)
create a MIME message builder for a given VCalendar
object.
void buildCalendarInviteMessage(VCalendar invite) {
final builder = VMessageBuilder.prepareFromCalendar(invite);
final mimeMessage = builder.buildMimeMessage();
print(mimeMessage);
// you can now send the MimeMessage as any other message, e.g. with `MailClient.sendMessage(mimeMessage)`
}
Use VMessageBuilder.prepareCalendarReply(...)
to create a reply MIME message for a received VCalendar.
In the following example the invite is accepted.
void buildAcceptReplyMessage(VCalendar invite) {
final me = MailAddress('Donna Strickland', '[email protected]');
final acceptMessageBuilder = VMessageBuilder.prepareCalendarReply(
invite,
ParticipantStatus.accepted,
me,
);
final mimeMessage = acceptMessageBuilder.buildMimeMessage();
print(mimeMessage);
}
Send a reply directly with the MailClient.sendCalendarReply()
instance method. This will generate the
mime message, send it and update the originating message's flags, when the message is specified and when the
mail service supports arbitrary message flags.
Future sendCalendarReply(
VCalendar calendar,
ParticipantStatus participantStatus,
MimeMessage originatingMessage,
MailClient mailClient,
) {
// generate reply email message, send it, set message flags:
return mailClient.sendCalendarReply(calendar, participantStatus,
originatingMessage: originatingMessage);
}
Use the calendarParticipantStatus
getter on a MimeMessage
instance to check for participation status flags that have been set earlier.
ParticipantStatus? getParticipantStatus(MimeMessage message) {
// the ParticipantStatus can be detected from the message flags when
//the flag was added successfully before
final participantStatus = message.calendarParticipantStatus;
if (participantStatus != null) {
print(
'detected ${participantStatus.name} through flag ${participantStatus.flag}');
} else {
print('no participant status flag detected in ${message.flags}');
}
return participantStatus;
}
enough_mail_icalendar
should be fully compliant with the iCalendar Message-Based Interoperability Protocol (iMIP) RFC 6047.
Please file feature requests and bugs at the issue tracker.
- Use enough_icalendar for managing iCalendar objects
- Use enough_mail for email management via IMAP, POP3 and SMTP
enough_mail_icalendar
is null-safe.
enough_mail_icalendar
is licensed under the commercial friendly Mozilla Public License 2.0