Parse TO: filed in mime

shk <>
Fri Mar 11 18:49:13 CET 2011


Hello,

I try to get TO:  field from mime mail message.

I have code:

parse_to(Data) ->
    List = string:tokens(Data, ":"),
    Sep1 = lists:map(fun(H) ->string:tokens(H, ":") end, List),
    io:format(Sep1),
    Sep2 = lists:filter(fun ([K | _]) -> K == "To" end, Sep1),
    ListAddress = lists:append(Sep2),
    [_ | Tail] = ListAddress,
    lists:map(fun(Address) -> string:tokens(Address, ",") end, Tail).
If i have short message for example: https://gist.github.com/865910 I got in
io:format(Sep1) https://gist.github.com/865905, it's ok all without :

But if i have long message with attachment: - https://gist.github.com/865914
I got in io:format(Sep1) - https://gist.github.com/865906 everything remains
the same as it was with :

What's wrong? Why shot message normal parse and big message not parsed?

When i try use regexp:

List = binary_to_list(Binary),
re:run(List, "^To: (.*)$", [multiline, {capture, all_but_first, list}]).

It's ok, but if i get Binary from file. If i get from erlang list [].

Thank you.

--
View this message in context: http://erlang.2086793.n4.nabble.com/Parse-TO-filed-in-mime-tp3348705p3348705.html
Sent from the Erlang Questions mailing list archive at Nabble.com.


More information about the erlang-questions mailing list