Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:35:11+00:00 2026-05-31T21:35:11+00:00

I am using the following code to get make an IMAP connection. I am

  • 0

I am using the following code to get make an IMAP connection. I am want to read emails. I read this documentation
link
and could not proceed from here.

my code:

#lang racket

(define imap-server "*****")
(define imap-port-no ***)
(define username "*****")
(define pw "*****")
(define mailbox-name "INBOX") 

(require openssl/mzssl
         net/imap
         mzlib/etc)

(define (test-connect)
  (let ([c (ssl-make-client-context)])
    (let-values ([(in out) (ssl-connect imap-server imap-port-no c)])
      (imap-connect* in out username pw mailbox-name))))

(define-values (imap cnt recent) (test-connect))

I am getting the count of emails and count of recent mails from this. How to proceed from here. which functions i should call to read emails.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:35:12+00:00Added an answer on May 31, 2026 at 9:35 pm

    Try something like this:

    (imap-get-messages imap '(1) '(uid flags header body))
    

    This should return a list holding the “fields” described by the flags, where header gives you the complete header part, and body is the email body. (This is just a quick experiment to see that things are working, you’ll need to know which messages to retrieve, etc — all described in the documentation.)

    Here’s a complete program that returns a list of the headers you want for each message in the INBOX, where each message gets an alist of the headers and their values as strings. But note that email is not really reliable for such things — you can receive a message regardless of what appears in the To: field, and there are many other header with similar semantics (for example, Resent-To: is similar to To:, sometimes there’s a Sender: header that can be more reliable than From:, etc.).

    #lang racket/base
    
    (define imap-server "imap.somewhere.com")
    (define imap-port-no 1234)
    (define username "----")
    (define pw "----")
    (define mailbox-name "INBOX")
    
    (require racket/list openssl/mzssl net/imap net/head)
    
    (define (test-connect)
      (let ([c (ssl-make-client-context)])
        (let-values ([(in out) (ssl-connect imap-server imap-port-no c)])
          (imap-connect* in out username pw mailbox-name))))
    
    (define-values [imap messages recent] (test-connect))
    
    (define (get-interesting-headers ns)
      (for/list ([x (imap-get-messages imap ns '(header))])
        (filter-map
         (λ (x)
           (define s
             (string->symbol (string-downcase (bytes->string/utf-8 (car x)))))
           (and (memq s '(from to date subject))
                (cons s (bytes->string/utf-8 (cdr x)))))
         (extract-all-fields (car x)))))
    (get-interesting-headers (for/list ([i messages]) (add1 i)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to get current latitude and longitude. But none of
I'm using the following code to get an array with all sub directories from
I am using the following code to get an XML data from a website
We are using the following code to get the groups of an active directory
I'm using the following code to get response from a requested page using php
I'm currently using the following PHP code: // Get all subordinates $subords = array();
Using following code I try to get updated list of checkbuttons' corresponding text values,
With the following code I get all the pages I admin on Facebook using
I am using following PHP code for trigger creation but always get error, please
In an iPhone app,we can make a UIBarButtonItem by using the following code: UIBarButtonItem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.