Where to find body of email depending of mimeType

后端 未结 5 1887
小蘑菇
小蘑菇 2020-12-01 09:53

I am making a request to the User.messages endpoint. All objects returned (the emails) have a mimeType property which I\'m struggling to understand.

More specificall

5条回答
  •  猫巷女王i
    2020-12-01 10:41

    I resolved this using a recursive function, in this way obtains all the text of the message without import the level of depth of the Json answer. If need more explication, please tell me.

     private List ObtenerTextoMensaje(IList partes)
        {
            var listaTextos = new List();
            foreach(var elementoParte in partes)
            {
                if ((elementoParte.MimeType == "text/plain")|| (elementoParte.MimeType == "text/html"))
                {
                    if (elementoParte.Body.Size != 0)
                    {
                        listaTextos.Add(decodificarBase64(elementoParte.Body.Data));                        
                    }
                }
                else
                {
                    if(elementoParte.Parts!=null)
                    listaTextos = ObtenerTextoMensaje(elementoParte.Parts);
                }
            }
            return listaTextos;
        }
    

提交回复
热议问题