Dart
Dart
Upload .eml File to an IMAP Mailbox
See more IMAP Examples
Demonstrates how to upload the MIME source of an email to a mailbox on an IMAP server.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final imap = CkImap();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Connect to an IMAP server.
// Use TLS
imap.ssl = true;
imap.port = 993;
try {
imap.connect('MY-IMAP-DOMAIN');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Login
try {
imap.login('MY-IMAP-LOGIN', 'MY-IMAP-PASSWORD');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final sbMime = CkStringBuilder();
sbMime.loadFile('qa_data/eml/emoji_pizza.eml', 'utf-8');
// Upload to the mailbox.
try {
imap.appendMime('[Gmail]/testFolder', sbMime.getAsString());
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
imap.disconnect();
print('OK.');
}