Open CGenie opened 5 years ago
Are you using master
?
Yes, I'm using master
, I liked the Lwt
code more than the socket mangling as in the .1.1.1
release.
I'm aware it's a WIP, however I hoped for a minimal working version here, or at least small thing that can get fixed :)
Can you tell which commit are you using? The current master has a completely different API which is not yet working.
I'm using the latest master
with small fixes on top of it: https://github.com/CGenie/ocaml-imap/tree/master-fix
My code looks like this:
Lwt_main.run begin
Imap.connect ~host:host ~port:port ~username:username ~password:password >>= fun imap ->
Imap.examine imap imap_cfg.mbox >>= fun () ->
Imap.uid_search imap Imap.Search.all >>= fun (uids, _) ->
(* Lwt_list.iter_s (fun (uid : Imap.uid) -> Lwt_io.printf "UID: %ld\n" uid) uids *)
Lwt_list.iter_s (fun (uid: Imap.uid) ->
let mime = Imap.MIME.Section.TEXT in
let msg = Imap.uid_fetch imap [uid] [Imap.Fetch.Request.body_section ~peek:true ~section:([], Some mime) ()] in
msg (fun resp ->
match resp with
| {Imap.Fetch.Response.body_section = [_, s]; _} ->
Utils.log_with_header "UID: %ld\nBody: %s" uid s
| _ ->
Utils.log_with_header "Error fetching message %ld\n" uid
)
) uids
>>= fun () -> Imap.disconnect imap
Probably due to https://github.com/CGenie/ocaml-imap/blob/master-fix/lib/parser.ml#L1156-L1161. You can try uncommenting that and seeing if it works. It may need some small changes to compile, not sure.
I can take a look but not right now, probably later in the day (no promises! :))
I'll try. Ah no hurry, your response is the fastest I've seen on github yet :)
Hello, I'm trying to run a simple
Imap.uid_search
followed byImap.uid_fetch
for aImap.Fetch.Request.body_section
. Hover I'm getting this error:Any idea what's wrong here?