(C#) Upload (Append) Email to an IMAP Mailbox
Upload / append an email to an IMAP mailbox.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Imap imap = new Chilkat.Imap();
// Connect to an IMAP server.
// Use TLS
imap.Ssl = true;
imap.Port = 993;
bool success = imap.Connect("imap.someMailServer.com");
if (success != true) {
Debug.WriteLine(imap.LastErrorText);
return;
}
// Login
success = imap.Login("myLogin","myPassword");
if (success != true) {
Debug.WriteLine(imap.LastErrorText);
return;
}
Chilkat.Email email = new Chilkat.Email();
// Load the email from a .eml file.
success = email.LoadEml("myEmail.eml");
if (success != true) {
Debug.WriteLine(email.LastErrorText);
return;
}
success = imap.AppendMail("Inbox",email);
if (success != true) {
Debug.WriteLine(imap.LastErrorText);
return;
}
Debug.WriteLine("Email uploaded to Inbox!");
// Disconnect from the IMAP server.
success = imap.Disconnect();
|