Reputation: 123
I'm trying to send emails using Google Apps Migration API v.1, however I fail to send them and Code does not throw any exception or error. Here is my code:
MailItemService mailItemService = new MailItemService("exampleCo-exampleApp-1");
mailItemService.setUserCredentials("user","password");
MailItemEntry entry = new MailItemEntry();
Rfc822MediaSource mediaSource = new Rfc822MediaSource(mail.getInputStream().toString());
entry.setMediaSource(mediaSource);
entry.addMailProperty(MailItemProperty.STARRED);
entry.addMailProperty(MailItemProperty.UNREAD);
entry.addLabel(new Label("pruebas"));
MailItemFeed feed = new MailItemFeed();
for (int i = 0; i < mailItems.size(); i++) {
BatchUtils.setBatchId(mailItems.get(i), Integer.toString(i));
feed.getEntries().add(mailItems.get(i));
}
mailItemService.batch("domain", "destinationUser", feed);
Upvotes: 0
Views: 94
Reputation: 13528
Can you define what you mean by "send"? It's against the APIs ToS to use it for anything other than migration of old mail to a mailbox (e.g. performing regular new message mailbox inserts is not allowed). If you're trying to send the mailbox new mail, use SMTP and/or IMAP.
Jay
Upvotes: 0