- while (*refs) {
- while (*refs && isspace (*refs))
- refs++;
- if (*refs == '<')
- refs++;
- end = refs;
- while (*end && !isspace (*end))
- end++;
- next = end;
- end--;
- if (end > refs && *end == '>')
- end--;
- if (end > refs) {
- g_ptr_array_add (array, g_strndup (refs, end - refs + 1));
- }
- refs = next;
+ refs = g_mime_references_decode (refs_str);
+
+ for (r = refs; r; r = r->next) {
+ message_id = g_mime_references_get_message_id (r);
+ g_ptr_array_add (array, g_strdup (message_id));