当前位置: 首页>>代码示例>>Java>>正文


Java Message.setToRecipients方法代码示例

本文整理汇总了Java中com.microsoft.outlookservices.Message.setToRecipients方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setToRecipients方法的具体用法?Java Message.setToRecipients怎么用?Java Message.setToRecipients使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.outlookservices.Message的用法示例。


在下文中一共展示了Message.setToRecipients方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Snippets,代码行数:31,代码来源:EmailSnippets.java

示例2: 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();
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Snippets,代码行数:41,代码来源:EmailSnippets.java

示例3: createAndSendMail

import com.microsoft.outlookservices.Message; //导入方法依赖的package包/类
/**
 * Creates and sends an email
 *
 * @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 sent email
 */
public String createAndSendMail(
        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 deliver the message.
    Message draft = mOutlookClient
            .getMe()
            .getMessages()
            .select("ID")
            .add(messageToSend)
            .get();
    mOutlookClient.getMe()
            .getOperations()
            .sendMail(draft, false)
            .get();
    return draft.getId();
}
 
开发者ID:OfficeDev,项目名称:O365-Android-Snippets,代码行数:45,代码来源:EmailSnippets.java


注:本文中的com.microsoft.outlookservices.Message.setToRecipients方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。