通过GMail API发送的电子邮件是空的

时间:2015-06-18 09:42:27

标签: gmail-api

我最近从Google App Engine MailServier切换到GMail API,我遇到了一个奇怪的问题: 电子邮件正在正确发送,但在收件人端,正文是空的! (主题仍在那里)。 我正在使用可选附件创建HTML电子邮件,并使用GMail API文档中的代码段对其进行编码:

我正在使用GMail API文档中的代码段对电子邮件进行编码:

#include <stdint.h>                     // Type definitions, e.g. uint8_t
//    #include "stdint-gcc.h"
#include <avr/power.h>                  // clock prescaler macro
#include <avr/interrupt.h>              // interrupt macros

在GMail中查看我的“已发送”文件夹时,我可以看到该消息很好(它是一个HTML电子邮件正文):

  public static Message createMessageWithEmail(MimeMessage email)
      throws MessagingException, IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    email.writeTo(baos);
    String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
    Message message = new Message();
    message.setRaw(encodedEmail);
    return message;
  }

在收件人端,同一条消息为空:

Received: from 889121556365-na05chj5g3il9flll2l3otqeh7q7ja22.apps.googleusercontent.com
    named unknown
    by gmailapi.google.com
    with HTTPREST;
    Thu, 18 Jun 2015 05:29:12 -0400
From: daniel.florey@gmail.com
To: daniel.florey@floreysoft.net
Message-Id: <CAHWc4t9o6gpRs_HT0Y8E1szJtDTwfSMS7OH+jVro-LiA1kBLJw@mail.gmail.com>
Subject: Test
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_1_15413936.1434619752068"
Date: Thu, 18 Jun 2015 05:29:12 -0400

------=_Part_1_15413936.1434619752068
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64


------=_Part_1_15413936.1434619752068
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64

TnVyIGVpbiBUZXN0ITxkaXY+PGJyPjwvZGl2PjxkaXY+PGZvbnQgc2l6ZT0iNiI+SGFoYWhhITwv
Zm9udD48L2Rpdj4=
------=_Part_1_15413936.1434619752068--

内容类型是否已切换为text / plain?! 有什么想法吗?

0 个答案:

没有答案