Visual FoxPro
Visual FoxPro
Read Gmail POP3 Mailbox
Reads the header for each email in a GMail POP3 mailbox and displays the FROM and SUBJECT header fields. In your GMail "Forwarding and POP" settings, be sure to select "When messages are accessed with POP keep Gmail's copy in the Inbox".Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMailman
LOCAL loBundle
LOCAL lnKeepOnServer
LOCAL lnHeadersOnly
LOCAL lnNumBodyLines
LOCAL i
LOCAL loEmail
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* The mailman object is used for receiving (POP3)
* and sending (SMTP) email.
loMailman = CreateObject('Chilkat.MailMan')
* Set the GMail account POP3 properties.
loMailman.MailHost = "pop.gmail.com"
loMailman.PopUsername = "myLogin"
loMailman.PopPassword = "myPassword"
loMailman.PopSsl = 1
loMailman.MailPort = 995
* Read mail headers and one line of the body.
* To get the full emails, set headersOnly = 0
loBundle = CreateObject('Chilkat.EmailBundle')
lnKeepOnServer = 1
lnHeadersOnly = 1
lnNumBodyLines = 1
lnSuccess = loMailman.FetchAll(lnKeepOnServer,lnHeadersOnly,lnNumBodyLines,loBundle)
IF (lnSuccess = 0) THEN
? loMailman.LastErrorText
RELEASE loMailman
RELEASE loBundle
CANCEL
ENDIF
i = 0
loEmail = CreateObject('Chilkat.Email')
DO WHILE i < loBundle.MessageCount
loBundle.EmailAt(i,loEmail)
* Display the From email address and the subject.
? "From: " + loEmail.From
? "Subject: " + loEmail.Subject
i = i + 1
ENDDO
RELEASE loMailman
RELEASE loBundle
RELEASE loEmail