我想从mime消息下载文本和html部分并将其存储在数据库中,以后需要下载附件。我需要这个,因为我不想将附件存储在我的数据库中以节省磁盘空间和带宽。它们将在以后按需下载。我不确定我是否可以这样做,仍然可以使用MimeKit的MimeParser
我打算这样做:
稍后我想在UI中显示该消息,但我想延迟解析,直到需要在UI中显示邮件消息。
这是我目前的进展
var msgSummaries = remoteFolder.Fetch(new int[] { remoteMessage.Index }, MessageSummaryItems.BodyStructure);
var stream = remoteFolder.GetStream(remoteMessage.Index, msgSummaries[0].HtmlBody.PartSpecifier);
//at this point i am saving the stream to the database and later i am trying to convert it to mime entity like that
var parser = new MimeParser(ParserOptions.Default, stream, true);
var mimeEntity = parser.ParseEntity(cancellationToken);
不幸的是,流不包含mime部分标题,无法解析,我也没有看到在GetStream方法中请求标题的选项
FETCH 1(BODY.PEEK [2.MIME] BODY.PEEK [2])
有什么建议吗?
答案 0 :(得分:1)
嗯,首先,你试过了吗?
import pygame as pg
WHITE = pg.Color('white')
class Tower2(pg.sprite.Sprite):
def __init__(self, pos, tRange=1, attackSpeed=1):
super().__init__()
self.image = your_image
self.image_clean = self.image
self.rect = self.image.get_rect()
self.rect.center = pos
self.angle = 0
def update(self):
self.angle += 10
self.image = pg.transform.rotate(self.image_clean, self.angle)
self.rect = self.image.get_rect(center=self.rect.center)
def main():
pg.init()
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
size = (SCREEN_WIDTH, SCREEN_HEIGHT)
screen = pg.display.set_mode(size)
done = False
clock = pg.time.Clock()
all_sprites = pg.sprite.Group()
turret = Tower2((SCREEN_WIDTH/2, SCREEN_HEIGHT/2))
all_sprites.add(turret)
while not done:
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
all_sprites.update()
screen.fill(WHITE)
all_sprites.draw(screen)
pg.display.flip()
clock.tick(15)
main()
pg.quit()
或者,如果你真的想使用流:
var mimeEntity = remoteFolder.GetBodyPart (remoteMessage.Index, msgSummaries[0].HtmlBody);