如何解码MimeType图像? [英] how to decode MimeType image ?

查看:80
本文介绍了如何解码MimeType图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Gmail Api提取电子邮件的内联附件(图片,邮件主体中的链接)。我不是在问一个关于Gmail Rest Api的事情我要问的是我怎样才能提取mimeType图像?这是代码,我只显示代码,因为我想知道让你知道我在玩什么...再次请忽略Gmail Api并帮助我找出解析邮件正文中的图像。



I am trying to extract email's inline attachments( images, links in the messagebody) using Gmail Api. I am not asking a thing about Gmail Rest Api what am I asking is how on earth could I extract mimeType images ? Here is the code, I am only showing the codes because I wanted to know let you know what I am playing around.. again please ignore Gmail Api and help me figure out parsing images from the message body.

Message message = service.Users.Messages.Get(userId, messageId).Execute();
                IList<MessagePart> parts = message.Payload.Parts;
               
                foreach (MessagePart p in parts)
                {
                   // Console.WriteLine("Boooo");
                    if (p.Filename!=null && p.Filename.Length>0)
                    {
                        if (p.MimeType == "image/jpeg")
                        {
                            MessagePartBody dd = message.Payload.Body;
                           // Here , I want to get images from message body.
                        }
                     //   Console.WriteLine("Poooo ");
                        String attId = p.Body.AttachmentId;
                        if (attId != null)
                        {
                            MessagePartBody attachPart = service.Users.Messages.Attachments.Get(userId, messageId, attId).Execute();

                            byte[] data = FromBase64ForUrlString(attachPart.Data);

                            string decodedString = Encoding.UTF8.GetString(data);
                            File.WriteAllBytes(Path.Combine(outputdir, p.Filename), data);
                       //     Console.WriteLine("Coooo");
                           // Console.WriteLine(decodedString);
                        }
                    }
                    }
                    Console.WriteLine(message.Snippet + " " + message.SizeEstimate);





任何帮助都将受到高度赞赏:)



最好的问候,



any help would be highly appreciated :)

best regards,

推荐答案

AC#的实施Mime De /编码 [ ^ ]试试这个


这篇关于如何解码MimeType图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆