Using Chilkat IMAP with Yahoo IMAP (imap.mail.yahoo.com)

From Wikipedia:

It is possible to get direct IMAP  access without signing up for paid access nor using software like YPOPs! or FreePOPs. Yahoo! operates IMAP and secure IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. However they require a specific, non-standard IMAP command to be sent before login is done, namely: “ID (“GUID” “1”)”.

Using Chilkat IMAP, you may send this command via the SendRawCommand method, as shown here (in pseudo-code)

responseString = imap.SendRawCommand(‘ID (“GUID” “1”)’);

The SendRawCommand method should be called after connecting, but before calling the Login method.

See these examples:
ASP: Yahoo! IMAP (imap.mail.yahoo.com)
SQL Server: Yahoo! IMAP (imap.mail.yahoo.com)
C#: Yahoo! IMAP (imap.mail.yahoo.com)
C++: Yahoo! IMAP (imap.mail.yahoo.com)
MFC: Yahoo! IMAP (imap.mail.yahoo.com)
C: Yahoo! IMAP (imap.mail.yahoo.com)
Delphi: Yahoo! IMAP (imap.mail.yahoo.com)
Visual FoxPro: Yahoo! IMAP (imap.mail.yahoo.com)
Java: Yahoo! IMAP (imap.mail.yahoo.com)
Perl: Yahoo! IMAP (imap.mail.yahoo.com)
PHP: Yahoo! IMAP (imap.mail.yahoo.com)
Python: Yahoo! IMAP (imap.mail.yahoo.com)
Ruby: Yahoo! IMAP (imap.mail.yahoo.com)
VB.NET: Yahoo! IMAP (imap.mail.yahoo.com)
Visual Basic: Yahoo! IMAP (imap.mail.yahoo.com)
VBScript: Yahoo! IMAP (imap.mail.yahoo.com)

Modify Email on IMAP Server?

Question:

I was wondering how it would be possible to make changes to an email on the server.

Answer:

Once an email is on a server, it cannot be modified.  This is not a Chilkat limitation, but it’s the way mail servers work.  However, with IMAP you may download an email, make changes, upload the new email to the mailbox via one of the Chilkat.Imap.Append* methods, and then delete the old email.  The new email will have a new UID assigned by the IMAP server, so it’s technically not the same email..

IMAP – Search for Messages by Message-ID or any Email Header Field

Using the Chilkat IMAP API: To download emails having the exact contents of a header field, or all emails where a given header field contains a specified substring, use the Search method like this:

    (C++)
    CkMessageSet *mset = imap.Search("HEADER Message-ID 48208D0C",true);

    (C#)
    Chilkat.MessageSet mset = imap.Search("HEADER Message-ID 48208D0C",true);

If the Search method returns a non-NULL message set object, then download the emails by calling FetchBundle:

    (C++)
    CkEmailBundle *bundle = imap.FetchBundle(mset);

    (C#)
    Chilkat.EmailBundle bundle = imap.FetchBundle(mset);

Once you have an email bundle object, you may iterate over the emails contained within the bundle.
See the IMAP examples at http://www.example-code.com/
(There are examples in many different programming languages)

IMAP “Not in the authenticated state” Error

The blog post explains the “Not in the authenticated state” error.

ChilkatLog:
SelectMailbox:
DllDate: Feb 15 2010
UnlockPrefix: Anything for 30-day trial
Username: NETWORK SERVICE
Component: .NET 2.0
mailbox: Inbox
Not in the authenticated state

This error happens if the caller is either not connected to an IMAP server, or is connected but the Login method was never called or did not complete successfully. It can happen for one of the following reasons:

  1. A previous IMAP method call failed because of a lost connection; perhaps the application did not check the return status for success failure. (It is important to check the return status of all method calls involving Internet communications.)
  2. The Connect and/or Login methods were never called.
  3. The return values of the Connect and/or Login methods were not checked for success/failure and a failure was not noticed.

IMAP: Select Public Folders

Question:

How can I access Public Folders in IMAP? This does not work:

imap.SelectMailbox(“Public Folders”)

Answer:

The syntax in Outlook may be different than what is actually
used in the underlying IMAP protocol. For example, in Outlook you may see
“public folders\all public folders\test”, but you would instead use:

imap.SelectMailbox(“public folders/test”)

Modify Email on IMAP Server?

Question:
Is it possible to change the Subject of an IMAP email?

Answer:

The IMAP protocol is such that emails (on the server) cannot be changed. This is not a Chilkat limitation, but it is the way IMAP works. In other words, if you want to change an email,
you can download it, make changes, then “append” the new email to the mailbox by calling one of the “Append*” methods, and then delete the old email. The new email will have a different UID.

Note: It is possible to modify the flags of an email (seen/unseen, flagged, answered, draft, deleted…)

Deleting email in GMail

(A tip from a Chilkat customer.)

The only way to delete emails on Gmail is in three steps:

1. Copy the email(s) to the folder called [Gmail]/Trash
2. Select all of the emails in [Gmail]/Trash and set the Deleted flag
3. Execute ExpungeAndClose or Expunge command

I found that this is the only way to truly delete emails from Gmail.

Understanding GMail’s Behavior

This blog post will explain GMail in a way that will help you understand it’s seemingly strange behavior. The question that prompted this post is as follows:

I am able to read mails from GMail mailbox using MailMan object. Is there any options to delete a mail permanently from GMail mailbox? When I am using the DeleteMail method the mail is going to the Trash folder, however I want it to be deleted permanently.

To explain GMail, I’ll first describe Outlook and then compare it to GMail.  Even though you already “know” Outlook, please read this because it’s important when comparing it to GMail.

Outlook is an email client application that runs on your computer.  It communicates with an email server to download emails.  The emails you’ve downloaded may or may not be deleted from the server, depending on your Outlook settings.  Outlook keeps it’s own “database” of emails saved locally on your filesystem.  These are the local folders: Inbox, Trash, Junk, etc. and the folders you’ve created.  Emails may be deleted from the mail server (POP3 or IMAP) but they will still be present in Outlook’s local storage.

GMail has the exact same model.  (I’ll explain)   GMail is an email application that runs on a Google server (not on your local computer).  The user interface is within a web browser.  Just like Outlook, the GMail application (running on Google’s web server) is an email client that communicates with a mail server.  In this case, it is Google’s mail server offering both POP3 and IMAP access.  (pop.gmail.com and imap.gmail.com)

Just like Outlook, the GMail application communicates with the mail server to download email messages, which it stores in it’s own local “database”.  (I double-quote the word database because it’s really just some sort of proprietary persistant storage of emails.)   What you see in the GMail web interface are the emails NOT on the mail server, but in the local folders of the GMail application — just like Outlook.

Looking at it this way should clear up the confusion.  If you delete an email via the GMail web user-interface, you are not deleting the email on the mail server,  you’re deleting the GMail application’s local copy.  If a POP3 or IMAP client (such as Chilkat) deletes an email from pop.gmail.com or imap.gmail.com, it is NOT deleting the GMail application’s local copy.  Expecting a POP3 or IMAP client component/library to delete the GMail application’s local copy is the same as expecting the component to delete Outlook’s local copy.  Email clients communicate with email servers.  Outlook and GMail are email client applications.  The Chilkat email component is also an email client.  Clients do not talk to clients.  Clients talk to servers.  GMail is a client, it can talk to pop.gmail.com and imap.gmail.com.  The same goes for Outlook, Mozilla Thunderbird, and the Chilkat components.

If you look at the GMail POP Download settings, it should now make sense to you:

GMail POP settings

The GMail application offers options just like Outlook — but the terminology they’ve chosen is confusing:

“Keep Gmail’s copy in the Inbox” really means “Do not delete the mail server’s copy”.

“Delete Gmail’s copy” really means “Delete the email from the mail server”.

I’m not sure what “archive GMail’s copy” is — I’d need to experiment.  It probably means something like: move the email to another folder on the mail server.  Perhaps an archive folder which can be accessed via the IMAP protocol.

Exchange Server – POP3, IMAP, and SMTP

Question:

May I ask if is possible use Chilkat components to connect to MS Exchange 6.5 and higher ?
I am thinking about purchase of MailMan component or other as it is, however I would like read some example in C# for reading emails from Exchange and sending emails via Exchange
after connecting to the specified account domain/logname & password.
May I see some examples somewhere on your site?
May you recommend correct components please ?

Answer:

Exchange Server (including v6.5 and higher) implements the server-side of the POP3, IMAP, and SMTP protocols.  Therefore, any software that implements the client-side of these protocols will work with Exchange Server in exactly the same way as any other email server. (See the note below regarding NTLM authentication.)

The purpose of a protocol is to allow any client-side implementation to communicate with any server-side implementation.  As long as each side correctly implements the protocol to specification, everything works.  For example, a web browser implements the client-side of the HTTP protocol.  You may not realize it, but it communicates with many different web server implementations: IIS, Apache, etc.  You can browse the web because the both clients (i.e. web browsers) and servers correctly implement the HTTP protocol.

Therefore, all of the examples involving POP3, SMTP, and IMAP at http://www.example-code.com are examples that will work with Exchange Server.

The Chilkat Email license ($99 for a 1-Developer license) is what you would need for the POP3 and SMTP functionality.  The Chilkat IMAP license ($199 for a 1-Developer license) includes all three: POP3, SMTP, and IMAP.  Note: 1-Developer does not mean “1-Computer”.  It simply means that one person may develop programs using the component.  All Chilkat licenses allow for royalty-free redistribution, meaning you may use the component/library on any number of computers.

*** MS Exchange implements an additional authentication mechanism called “NTLM”, which is also known as Windows Integrated Authentication.   Chilkat supports NTLM for POP3, IMAP, and SMTP.