use of com.microsoft.graph.models.Message in project msgraph-beta-sdk-java by microsoftgraph.
the class OutlookTests method testSendDraft.
@Test
public void testSendDraft() {
TestBase testBase = new TestBase();
// Attempt to identify the sent message via randomly generated subject
String draftSubject = "Draft Test Message " + Double.toString(Math.random() * 1000);
Message newMessage = createDraftMessage(testBase, draftSubject);
// Send the drafted message
testBase.graphClient.me().mailFolders("Drafts").messages(newMessage.id).send().buildRequest().post();
// Check that the sent message exists on the server
MessageCollectionPage mcp = testBase.graphClient.me().messages().buildRequest().filter("subject eq '" + draftSubject + "'").get();
assertFalse(mcp.getCurrentPage().isEmpty());
}
use of com.microsoft.graph.models.Message in project msgraph-beta-sdk-java by microsoftgraph.
the class OutlookTests method testSendMail.
@Test
public void testSendMail() {
TestBase testBase = new TestBase();
User me = testBase.graphClient.me().buildRequest().get();
Recipient r = new Recipient();
EmailAddress address = new EmailAddress();
address.address = me.mail;
r.emailAddress = address;
Message message = new Message();
message.subject = "Test E-Mail";
message.from = r;
ArrayList<Recipient> recipients = new ArrayList<Recipient>();
recipients.add(r);
message.toRecipients = recipients;
testBase.graphClient.me().sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();
}
use of com.microsoft.graph.models.Message in project msgraph-beta-sdk-java by microsoftgraph.
the class OutlookTests method sendEmailWithAttachment.
@Test
public void sendEmailWithAttachment() throws Exception {
TestBase testBase = new TestBase();
Message message = getMessage();
message.hasAttachments = true;
AttachmentCollectionResponse response = new AttachmentCollectionResponse();
response.value = Arrays.asList(getFileAttachment(), getItemAttachmentWithEvent(), getItemAttachmentWithContact());
message.attachments = new AttachmentCollectionPage(response, null);
testBase.graphClient.me().sendMail(UserSendMailParameterSet.newBuilder().withMessage(message).withSaveToSentItems(true).build()).buildRequest().post();
}
use of com.microsoft.graph.models.Message in project msgraph-beta-sdk-java by microsoftgraph.
the class OutlookTests method uploadEmailAsDraftWithAttachmentThenSend.
@Test
public void uploadEmailAsDraftWithAttachmentThenSend() {
TestBase testBase = new TestBase();
Message message = getMessage();
Message m = testBase.graphClient.me().messages().buildRequest().post(message);
assertNotNull(m);
testBase.graphClient.me().messages(m.id).send().buildRequest().post();
}
use of com.microsoft.graph.models.Message in project team-catalog by navikt.
the class MailMessage method compose.
public static Message compose(String to, String subject, String messageBody) {
Message message = new Message();
message.toRecipients = List.of(recipient(to));
message.subject = subject;
message.body = new ItemBody();
message.body.contentType = BodyType.HTML;
message.body.content = messageBody;
return message;
}
Aggregations