第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

郵件分段/替代vs分段/混合

郵件分段/替代vs分段/混合

小唯快跑啊 2019-11-05 11:24:48
當(dāng)創(chuàng)建的電子郵件,你都應(yīng)該設(shè)置內(nèi)容類型來multipart/alternative發(fā)送HTML和文本時,或multipart/mixed發(fā)送文本和附件時。如果要發(fā)送HTML,文本和附件,該怎么辦?同時使用?
查看完整描述

3 回答

?
蝴蝶刀刀

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個贊

使用multipart/mixed與第一部分為multipart/alternative及以后的零件的附件。反過來,在零件內(nèi)使用text/plaintext/html零件multipart/alternative

有能力的電子郵件客戶端應(yīng)然后識別該multipart/alternative部分,并在必要時顯示文本部分或html部分。它還應(yīng)將所有隨后的零件顯示為附件。

這里要注意的重要一點(diǎn)是,在多部分MIME消息中,部分內(nèi)包含部分是完全有效的。從理論上講,嵌套可以擴(kuò)展到任何深度。然后,任何具有合理能力的電子郵件客戶端都應(yīng)該能夠遞歸處理所有消息部分。


查看完整回答
反對 回復(fù) 2019-11-05
?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個贊

消息有內(nèi)容。內(nèi)容可以是文本,html,DataHandler或Multipart,并且只能有一個內(nèi)容。多個零件只有身體零件,但可以有多個零件。像消息一樣,BodyParts可以包含已經(jīng)描述的內(nèi)容。


帶有HTML,文本和附件的消息可以按如下所示分層查看:


message

  mainMultipart (content for message, subType="mixed")

    ->htmlAndTextBodyPart (bodyPart1 for mainMultipart)

      ->htmlAndTextMultipart (content for htmlAndTextBodyPart, subType="alternative")

        ->textBodyPart (bodyPart2 for the htmlAndTextMultipart)

          ->text (content for textBodyPart)

        ->htmlBodyPart (bodyPart1 for htmlAndTextMultipart)

          ->html (content for htmlBodyPart)

    ->fileBodyPart1 (bodyPart2 for the mainMultipart)

      ->FileDataHandler (content for fileBodyPart1 )

以及構(gòu)建此類消息的代碼:


    // the parent or main part if you will

    Multipart mainMultipart = new MimeMultipart("mixed");


    // this will hold text and html and tells the client there are 2 versions of the message (html and text). presumably text

    // being the alternative to html

    Multipart htmlAndTextMultipart = new MimeMultipart("alternative");


    // set text

    MimeBodyPart textBodyPart = new MimeBodyPart();

    textBodyPart.setText(text);

    htmlAndTextMultipart.addBodyPart(textBodyPart);


    // set html (set this last per rfc1341 which states last = best)

    MimeBodyPart htmlBodyPart = new MimeBodyPart();

    htmlBodyPart.setContent(html, "text/html; charset=utf-8");

    htmlAndTextMultipart.addBodyPart(htmlBodyPart);


    // stuff the multipart into a bodypart and add the bodyPart to the mainMultipart

    MimeBodyPart htmlAndTextBodyPart = new MimeBodyPart();

    htmlAndTextBodyPart.setContent(htmlAndTextMultipart);

    mainMultipart.addBodyPart(htmlAndTextBodyPart);


    // attach file body parts directly to the mainMultipart

    MimeBodyPart filePart = new MimeBodyPart();

    FileDataSource fds = new FileDataSource("/path/to/some/file.txt");

    filePart.setDataHandler(new DataHandler(fds));

    filePart.setFileName(fds.getName());

    mainMultipart.addBodyPart(filePart);


    // set message content

    message.setContent(mainMultipart);


查看完整回答
反對 回復(fù) 2019-11-05
  • 3 回答
  • 0 關(guān)注
  • 434 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號