Search in sources :

Example 1 with ItemBody

use of com.microsoft.graph.extensions.ItemBody in project android-java-snippets-sample by microsoftgraph.

the class EventsSnippets method createEventObject.

private static Event createEventObject() {
    Event event = new Event();
    event.subject = "Microsoft Graph SDK Discussion";
    // set start time to now
    DateTimeTimeZone start = new DateTimeTimeZone();
    start.dateTime = DateTime.now().toString();
    event.start = start;
    // and end in 1 hr
    DateTimeTimeZone end = new DateTimeTimeZone();
    end.dateTime = DateTime.now().plusHours(1).toString();
    event.end = end;
    // set the timezone
    start.timeZone = end.timeZone = "UTC";
    // set a location
    Location location = new Location();
    location.displayName = "Bill's Office";
    event.location = location;
    // add attendees
    Attendee attendee = new Attendee();
    attendee.type = AttendeeType.required;
    attendee.emailAddress = new EmailAddress();
    attendee.emailAddress.address = "mara@fabrikam.com";
    event.attendees = Collections.singletonList(attendee);
    // add a msg
    ItemBody msg = new ItemBody();
    msg.content = "Let's discuss the Microsoft Graph SDK.";
    msg.contentType = BodyType.text;
    event.body = msg;
    return event;
}
Also used : ItemBody(com.microsoft.graph.extensions.ItemBody) Event(com.microsoft.graph.extensions.Event) DateTimeTimeZone(com.microsoft.graph.extensions.DateTimeTimeZone) Attendee(com.microsoft.graph.extensions.Attendee) EmailAddress(com.microsoft.graph.extensions.EmailAddress) Location(com.microsoft.graph.extensions.Location)

Example 2 with ItemBody

use of com.microsoft.graph.extensions.ItemBody in project android-java-snippets-sample by microsoftgraph.

the class MessageSnippets method createMessageObject.

private static Message createMessageObject() {
    // Get a context so we can interrogate Resources & SharedPreferences
    SnippetApp app = SnippetApp.getApp();
    SharedPreferences prefs = SharedPrefsUtil.getSharedPreferences();
    Message message = new Message();
    Recipient recipient = new Recipient();
    recipient.emailAddress = new EmailAddress();
    recipient.emailAddress.address = prefs.getString(SharedPrefsUtil.PREF_USER_ID, "");
    message.toRecipients = Collections.singletonList(recipient);
    message.subject = app.getString(R.string.mail_subject);
    ItemBody itemBody = new ItemBody();
    itemBody.contentType = BodyType.text;
    itemBody.content = app.getString(R.string.mail_body);
    message.body = itemBody;
    return message;
}
Also used : SnippetApp(com.microsoft.graph.snippets.application.SnippetApp) Message(com.microsoft.graph.extensions.Message) ItemBody(com.microsoft.graph.extensions.ItemBody) SharedPreferences(android.content.SharedPreferences) Recipient(com.microsoft.graph.extensions.Recipient) EmailAddress(com.microsoft.graph.extensions.EmailAddress)

Aggregations

EmailAddress (com.microsoft.graph.extensions.EmailAddress)2 ItemBody (com.microsoft.graph.extensions.ItemBody)2 SharedPreferences (android.content.SharedPreferences)1 Attendee (com.microsoft.graph.extensions.Attendee)1 DateTimeTimeZone (com.microsoft.graph.extensions.DateTimeTimeZone)1 Event (com.microsoft.graph.extensions.Event)1 Location (com.microsoft.graph.extensions.Location)1 Message (com.microsoft.graph.extensions.Message)1 Recipient (com.microsoft.graph.extensions.Recipient)1 SnippetApp (com.microsoft.graph.snippets.application.SnippetApp)1