librelist archives

« back to archive

Error while fetching body

Error while fetching body

From:
Prasanna Chitnis
Date:
2013-10-23 @ 06:29
Hi ,
	I am using Remail app to build sample mail cline app on IOS, and i am 
facing problem while fetching the message body.
	The libetpan lib gives error while fetching , following lines of code 
where this happens:
     fetch_imap:returns error.
following is the code of that function:

fetch_imap(mailmessage * msg,
	   struct mailimap_fetch_type * fetch_type,
	   char ** result, size_t * result_len)
{
  int r;
  struct mailimap_msg_att * msg_att;
  struct mailimap_msg_att_item * msg_att_item;
  clist * fetch_result;
  struct mailimap_set * set;
  char * text;
  size_t text_length;
  clistiter * cur;

  set = mailimap_set_new_single(msg->msg_index);
  if (set == NULL)
    return MAIL_ERROR_MEMORY;

  r = mailimap_uid_fetch(get_imap_session(msg), set,
			 fetch_type, &fetch_result);

  mailimap_set_free(set);

  switch (r) {
  case MAILIMAP_NO_ERROR:
    break;
  default:
    return imap_error_to_mail_error(r);
  }

  if (clist_begin(fetch_result) == NULL) {
    mailimap_fetch_list_free(fetch_result);
    return MAIL_ERROR_FETCH;
  }

  msg_att = clist_begin(fetch_result)->data;

  text = NULL;
  text_length = 0;

  for(cur = clist_begin(msg_att->att_list) ; cur != NULL ;
      cur = clist_next(cur)) {
    msg_att_item = clist_content(cur);

    if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {

      if (msg_att_item->att_data.att_static->att_type ==
	  MAILIMAP_MSG_ATT_BODY_SECTION) {
	text = 
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
	
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part
= NULL;
	text_length =
	  msg_att_item->att_data.att_static->att_data.att_body_section->sec_length;
      }
    }
  }
The text will be NULL for some mails so it returns MAIL_ERROR_FETCH, any 
one know why for certain mails this method fails to get text? i am using 
our own IMAP server.


Thanks & Regards,
Prasanna Chitnis.





-----------------------------------------------
Robosoft Technologies - Emotion Engineering & Design

Disclaimer: This email may contain confidential material. If you were not 
an intended recipient, please notify the sender and delete all copies. 
Emails to and from our network may be logged and monitored. This email and
its attachments are scanned for virus by our scanners and are believed to 
be safe. However, no warranty is given that this email is free of 
malicious content or virus.