Dart
Dart
Upload (Append) Email to an IMAP Mailbox
Upload / append an email to an IMAP mailbox.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final imap = CkImap();
// Connect to an IMAP server.
// Use TLS
imap.ssl = true;
imap.port = 993;
try {
imap.connect('imap.example.com');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Login
try {
imap.login('myLogin', 'myPassword');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final email = CkEmail();
// Load the email from a .eml file.
try {
email.loadEml('myEmail.eml');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
try {
imap.appendMail('Inbox', email);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Email uploaded to Inbox!');
// Disconnect from the IMAP server.
imap.disconnect();
}