mail_fetchstructure (vms->mailstream,vms->msgArray[vms->curmsg],&body);
/* We have the body, now we extract the file name of the first attachment. */
- if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+ if (body->nested.part && body->nested.part->next && body->nested.part->next->body.parameter->value) {
attachedfilefmt = ast_strdupa(body->nested.part->next->body.parameter->value);
} else {
ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
for (i = 0; i < vms_p->mailstream->nmsgs; i++) {
mail_fetchstructure(vms_p->mailstream, i + 1, &body);
/* We have the body, now we extract the file name of the first attachment. */
- if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+ if (body->nested.part && body->nested.part->next && body->nested.part->next->body.parameter->value) {
attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
} else {
ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");