java - 在草稿状态 Microsoft Graph API Java 中发布消息创建消息

标签 java microsoft-graph-api

当我尝试使用 Microsoft Graph Java API 发送消息时,它的状态为草稿。

Authentication.initialize(appId);
    final String accessToken = Authentication.getUserAccessToken(appScopes);

    authProvider = new SimpleAuthProvider(accessToken);

    // Create default logger to only log errors
    DefaultLogger logger = new DefaultLogger();
    logger.setLoggingLevel(LoggerLevel.DEBUG);

    // Build a Graph client
    graphClient = GraphServiceClient.builder()
        .authenticationProvider(authProvider)
        .logger(logger)
        .buildClient();

    IMailFolderDeltaCollectionPage mailFolderCollectionPage = graphClient.me().mailFolders().delta()
        .buildRequest().get();
    AtomicReference<String> inBoxFolderId = new AtomicReference<>("");
    while (mailFolderCollectionPage.getNextPage() != null) {
      List<MailFolder> mailFolders = mailFolderCollectionPage.getCurrentPage();
      mailFolders.forEach(m -> {
        if (m.displayName.equals("Inbox")) {
          inBoxFolderId.set(m.id);
        }
          });

      mailFolderCollectionPage = mailFolderCollectionPage.getNextPage().buildRequest().get();
    }

    IMessageDeltaCollectionPage messageCollectionPage = graphClient.me().mailFolders("Inbox")
        .messages().delta().buildRequest().get();

    Message backedMessaged = null;

    while (messageCollectionPage.getNextPage() != null) {
      System.out.println("messageCollectionPage = " + messageCollectionPage);
      List<Message> messageList = messageCollectionPage.getCurrentPage();
      backedMessaged = messageList.get(0);
      break;
    }

   graphClient.me().mailFolders("Inbox").messages().buildRequest().post(backedMessaged);

最佳答案

当您创建 Outlook 邮件时,其状态将保持为草稿状态,直到您发送为止。您应该使用 send 请求来发送消息。然后它将不再被标记为草稿。

查看此处了解更多信息:https://learn.microsoft.com/fr-fr/graph/api/message-send?view=graph-rest-1.0&tabs=http

关于java - 在草稿状态 Microsoft Graph API Java 中发布消息创建消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59766382/

相关文章:

node.js - 我获得了 microsoft graph 的身份验证代码,但是当我尝试使用它时,响应是 InvalidAuthenticationToken

java - MVC 模式 : which is better? 为 View 或 Controller 创建和引用其他?

java - Spring Java Maven项目+模块设计

azure - 如何通过 C# 检测正在使用的 Azure AD 版本?

asp.net-core - 从 Net Core WebApi 后端的前端验证 Azure Bearer token

azure - 使用 Microsoft Identity 获取 Graph 和 Azure DevOps API 的唯一 token

java - C附加到现有的jvm

java - Spring MVC 的问题。如何从两个或多个对象创建 View ?

java - 避免在 Spring Rest 文件下载调用中使用 CoyoteOutputStream 对象签名

microsoft-graph-api - 端点 "Get analytics"返回空响应