本文整理汇总了Java中com.microsoft.outlookservices.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于com.microsoft.outlookservices包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessage
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
public O365Mail_Message createMessage(String subject)
{
// Create a temporary unique message Id for the new message. The
// temporary Id is used by the ListView to uniquely id the new message
// when it is added to the local cache before posting to the Outlook service
UUID ID = java.util.UUID.randomUUID();
// Cache the temp Id in the message model so the model can retrieve the
// message out of the ITEMS_MAP map and update with the Id assigned by
// Outlook service upon successful add
tempNewMessageId = ID;
// The com.microsoft.office365.OutlookServices.message is created
// and cached in the message model
Message newMessage = new Message();
O365Mail_Message newMessageModel = new O365Mail_Message(subject, newMessage);
newMessageModel.setID(ID.toString());
return newMessageModel;
}
示例2: loadMessagesIntoModel
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
private void loadMessagesIntoModel(List<Message> message)
{
try
{
this.getMail().ITEMS.clear();
this.getMail().ITEM_MAP.clear();
for (Message m : message)
{
O365Mail_Message mailMessage = this.createMessage(m.getId(), m);
ItemBody itemBody = m.getBody();
if (itemBody != null)
{
mailMessage.setItemBody(m.getBody());
}
mailMessage.setSubject(m.getSubject());
addItem(mailMessage);
}
}
catch (Exception ex)
{
String exceptionMessage = ex.getMessage();
Log.e("RetrievemessagesTask", exceptionMessage);
}
}
示例3: GetAMessageFromEmailFolder
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets first message found with the given subject line from the user's inbox.
* Uses a polling technique because typically the message was just sent and there
* is a small wait time until it arrives.
*
* @param emailSnippets Snippets which contains a message search snippet that is needed
* @param subjectLine The subject line to search for
* @return
* @throws ExecutionException
* @throws InterruptedException
*/
protected Message GetAMessageFromEmailFolder(EmailSnippets emailSnippets, String subjectLine, String folderName)
throws ExecutionException, InterruptedException {
Message message = null;
int tryCount = 0;
//Continue trying to get the email while the email is not found
//and the loop has tried less than MAX_POLL_REQUESTS times.
do {
List<Message> messages;
messages = emailSnippets
.getMailboxMessagesByFolderNameSubject(
subjectLine
, folderName);
if (messages.size() > 0) {
message = messages.get(0);
}
tryCount++;
Thread.sleep(THREAD_SLEEP_TIME);
//Stay in loop while these conditions are true.
//If either condition becomes false, break
} while (message == null && tryCount < MAX_POLL_REQUESTS);
return message;
}
示例4: getMailMessages
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets a list of the 10 most recent email messages in the
* user Inbox, sorted by date and time received.
*
* @return List of type com.microsoft.outlookservices.Message
*/
public List<Message> getMailMessages()
throws ExecutionException, InterruptedException {
List<Message> messages = mOutlookClient
.getMe()
.getFolders()
.getById("Inbox")
.getMessages()
.select("Subject")
.orderBy("DateTimeReceived desc")
.top(10)
.read()
.get();
return messages;
}
示例5: getInboxMessagesBySubject
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets a list of all recent email messages in the
* user Inbox whose subject matches, sorted by date and time received
*
* @param subjectLine The subject of the email to be matched
* @return List of String. The mail Ids of the matching messages
* @see 'https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar'
*/
public List<String> getInboxMessagesBySubject(String subjectLine)
throws ExecutionException, InterruptedException {
List<Message> inboxMessages = mOutlookClient
.getMe()
.getFolders()
.getById("Inbox")
.getMessages()
.filter("Subject eq '" + subjectLine.trim() + "'")
.read()
.get();
ArrayList<String> mailIds = new ArrayList<>();
for (Message message : inboxMessages) {
mailIds.add(message.getId());
}
return mailIds;
}
示例6: getMailboxMessagesByFolderNameSubject
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets a list of all recent email messages in the
* named mail folder whose subject matches, sorted by date and time received
*
* @param subjectLine The subject of the email to be matched
* @param folderName The display name of the mail folder
* @return List of String. The mail Ids of the matching messages
* @see 'https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar'
*/
public List<Message> getMailboxMessagesByFolderNameSubject(
String subjectLine
, String folderName) throws ExecutionException, InterruptedException {
List<Folder> sentFolder = mOutlookClient.getMe()
.getFolders()
.select("ID")
.filter("DisplayName eq '" + folderName + "'")
.read()
.get();
return mOutlookClient
.getMe()
.getFolder(sentFolder.get(0).getId())
.getMessages()
.select("ID")
.filter("Subject eq '" + subjectLine.trim() + "'")
.read()
.get();
}
示例7: forwardDraftMail
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Forwards a message out of the user's Inbox folder by id
*
* @param emailId The id of the mail to be forwarded
* @param recipientEmailAddress The email address string of the recipient
* @return String. The id of the sent email
*/
public String forwardDraftMail(String emailId, String recipientEmailAddress) throws ExecutionException, InterruptedException {
Message forwardMessage = mOutlookClient
.getMe()
.getMessages()
.getById(emailId)
.getOperations()
.createForward()
.get();
//Get the new draft email to forward to the specified email recipient
Message draftMessage = getDraftMessageMap()
.get(forwardMessage.getConversationId());
//Set the recipient list for the draft message
draftMessage.setToRecipients(createEmailRecipientList(recipientEmailAddress));
mOutlookClient
.getMe()
.getOperations()
.sendMail(draftMessage, false)
.get();
return draftMessage.getId();
}
示例8: DeleteAMessageFromMailFolder
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
protected void DeleteAMessageFromMailFolder(
EmailSnippets emailSnippets
, String subjectLine, String folderName)
throws ExecutionException, InterruptedException {
List<Message> messagesToDelete;
int tryCount = 0;
//Try to get the newly sent email from user's inbox at least once.
//continue trying to get the email while the email is not found
//and the loop has tried less than 50 times.
do {
messagesToDelete = emailSnippets
.getMailboxMessagesByFolderNameSubject(
subjectLine
, folderName);
for (Message message : messagesToDelete) {
//3. Delete the email using the ID
emailSnippets.deleteMail(message.getId());
}
tryCount++;
Thread.sleep(THREAD_SLEEP_TIME);
//Stay in loop while these conditions are true.
//If either condition becomes false, break
} while (messagesToDelete.size() == 0 && tryCount < MAX_POLL_REQUESTS);
}
示例9: execute
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
@Override
public String execute() {
String returnResult;
AuthenticationController
.getInstance()
.setResourceId(
getO365MailResourceId());
try {
EmailSnippets emailSnippets = new EmailSnippets(
getO365MailClient());
//O365 API called in this helper
List<Message> messages = emailSnippets.getMailMessages();
//build string for test results on UI
StringBuilder sb = new StringBuilder();
sb.append("Gets email: " + messages.size() + " messages returned");
sb.append("\n");
for (Message m : messages) {
sb.append("\t\t");
sb.append(m.getSubject());
sb.append("\n");
}
returnResult = StoryResultFormatter.wrapResult(sb.toString(), true);
} catch (ExecutionException | InterruptedException e) {
return FormatException(e, STORY_DESCRIPTION);
}
return returnResult;
}
示例10: execute
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
@Override
public String execute() {
AuthenticationController
.getInstance()
.setResourceId(
getO365MailResourceId());
try {
EmailSnippets emailSnippets = new EmailSnippets(
getO365MailClient());
//1. Send an email and store the ID
String uniqueGUID = java.util.UUID.randomUUID().toString();
emailSnippets.createAndSendMail(
GlobalValues.USER_EMAIL
, getStringResource(R.string.mail_subject_text)
+ uniqueGUID, getStringResource(R.string.mail_body_text));
//Get the new message
Message messageToForward = GetAMessageFromEmailFolder(emailSnippets,
getStringResource(R.string.mail_subject_text)
+ uniqueGUID, getStringResource(R.string.Email_Folder_Inbox));
String forwardEmailId = emailSnippets.forwardDraftMail(messageToForward.getId(),GlobalValues.USER_EMAIL);
//3. Delete the email using the ID
emailSnippets.deleteMail(messageToForward.getId());
if (forwardEmailId.length() > 0) {
emailSnippets.deleteMail(forwardEmailId);
}
return StoryResultFormatter.wrapResult(
STORY_DESCRIPTION, true
);
} catch (ExecutionException | InterruptedException ex) {
return FormatException(ex, STORY_DESCRIPTION);
}
}
示例11: execute
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
@Override
public String execute() {
String returnResult;
try {
AuthenticationController
.getInstance()
.setResourceId(
getO365MailResourceId());
EmailSnippets emailSnippets = new EmailSnippets(
getO365MailClient());
//1. Send an email and store the ID
String uniqueGUID = java.util.UUID.randomUUID().toString();
String subject = getStringResource(R.string.mail_subject_text) + uniqueGUID;
emailSnippets.createAndSendMail(GlobalValues.USER_EMAIL,
subject,
getStringResource(R.string.mail_body_text));
//3. Delete the email using the ID
Message message = GetAMessageFromEmailFolder(emailSnippets, subject, getStringResource(R.string.Email_Folder_Inbox));
emailSnippets.deleteMail(message.getId());
returnResult = StoryResultFormatter.wrapResult("Email is added", true);
} catch (Exception e) {
return FormatException(e, STORY_DESCRIPTION);
}
return returnResult;
}
示例12:
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Demonstrates how to specify the $select OData system query option.
* Gets a list of the 10 email messages selecting only the from, subject,
* and isRead fields. Use the .select() method to specify a $select query
* as shown in this snippet.
* <p/>
* For a complete list of types and properties that can be selected
* see https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#OdataQueryParams
*
* @return List of type com.microsoft.outlookservices.Message
*/
public List<Message> getMailMessagesUsing$select(OutlookClient outlookClient)
throws ExecutionException, InterruptedException {
List<Message> messages = outlookClient
.getMe()
.getFolders()
.getById("Inbox")
.getMessages()
.select("from,subject,isRead")
.top(10)
.read().get();
return messages;
}
示例13: getMailMessageById
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets an email message by the id of the desired message
*
* @return com.microsoft.outlookservices.Message
*/
public Message getMailMessageById(String mailId)
throws ExecutionException, InterruptedException {
return mOutlookClient
.getMe()
.getMessages()
.select("ID")
.getById(mailId)
.read()
.get();
}
示例14: getInboxMessagesBySubject_DateTimeReceived
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets a list of all recent email messages in the
* user Inbox whose subject matches subjectLine and sent date&time are greater than the
* sentDate parameter. Results are sorted by date and time received
*
* @param subjectLine The subject of the email to be matched
* @param sentDate The UTC (Zulu) time that the mail was sent.
* @return List of String. The mail Ids of the matching messages
* @see 'https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar'
*/
public List<String> getInboxMessagesBySubject_DateTimeReceived(
String subjectLine,
Date sentDate,
String mailFolder) throws ExecutionException, InterruptedException {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
String filterString = "DateTimeReceived ge "
+ formatter.format(sentDate.getTime())
+ " and "
+ "Subject eq '"
+ subjectLine.trim() + "'";
List<Message> inboxMessages = mOutlookClient
.getMe()
.getFolders()
.getById(mailFolder)
.getMessages()
.select("ID")
.filter(filterString)
.read()
.get();
ArrayList<String> mailIds = new ArrayList<>();
for (Message message : inboxMessages) {
if (message.getSubject().equals(subjectLine.trim()))
mailIds.add(message.getId());
}
return mailIds;
}
示例15: addDraftMail
import com.microsoft.outlookservices.Message; //导入依赖的package包/类
/**
* Gets a message out of the user's draft folder by id and adds a text file attachment
*
* @param emailAddress The email address of the mail recipient
* @param subject The subject of the email
* @param body The body of the email
* @return String. The id of the email added to the draft folder
*/
public String addDraftMail(
final String emailAddress,
final String subject,
final String body) throws ExecutionException, InterruptedException {
// Prepare the message.
List<Recipient> recipientList = new ArrayList<>();
Recipient recipient = new Recipient();
EmailAddress email = new EmailAddress();
email.setAddress(emailAddress);
recipient.setEmailAddress(email);
recipientList.add(recipient);
Message messageToSend = new Message();
messageToSend.setToRecipients(recipientList);
ItemBody bodyItem = new ItemBody();
bodyItem.setContentType(BodyType.HTML);
bodyItem.setContent(body);
messageToSend.setBody(bodyItem);
messageToSend.setSubject(subject);
// Contact the Office 365 service and try to add the message to
// the draft folder.
Message draft = mOutlookClient
.getMe()
.getMessages()
.add(messageToSend)
.get();
return draft.getId();
}