Office.context.mailbox.item.addFileAttachmentAsync该代码正常工作。为什么发生内部错误?

时间:2019-12-26 14:35:01

标签: outlook-web-addins

以前,代码正常工作。为什么发生内部错误?

Office的JavaScript API是否有问题?

https://docs.microsoft.com/en-us/outlook/add-ins/add-and-remove-attachments-to-an-item-in-a-compose-form

链接和标题正确。我检查了。

class MainActivity extends AppCompatActivity {
    int ch=1;
    float font=30;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final TextView t= (TextView) findViewById(R.id.textView);
        Button b1= (Button) findViewById(R.id.button1);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                t.setTextSize(font);
                font = font + 5;
                if(font == 50)
                    font = 30;
            }
        });

        Button b2= (Button) findViewById(R.id.button2);
        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch(ch) {
                    case 1:
                        t.setTextColor(Color.RED);
                        break;
                    case 2:
                        t.setTextColor(Color.GREEN);
                        break;
                    case 3:
                        t.setTextColor(Color.BLUE);
                        break;
                    case 4:
                        t.setTextColor(Color.CYAN);
                        break;
                    case 5:
                        t.setTextColor(Color.YELLOW);
                        break;
                    case 6:
                        t.setTextColor(Color.MAGENTA);
                        break;
                }
                ch++;
                if(ch == 7)
                    ch = 1;
            }
        });
    }
}

我有一个asyncResult:

                  var options = {
                    asyncContext: null
                  };


                  Office.context.mailbox.item.addFileAttachmentAsync(link, title, options, function (asyncResult) {
                    console.log("asyncResult: " + JSON.stringify(asyncResult));
                    if (asyncResult.status === "succeeded") {
                      $docName.prepend("<i class='ms-Icon ms-Icon--checkbox ms-font-m ms-fontColor-green'>");
                      $fileProcess.resolve();
                    } else {
                      console.log("Office.context.mailbox.item.addFileAttachmentAsync() [" + asyncResult.status + "] error: "//
                        + JSON.stringify(asyncResult.error) + " value: " + JSON.stringify(asyncResult.value));
                      $fileProcess.reject();
                      $attachedDoc.addClass("ms-bgColor-error");
                      $docName.prepend("<i class='ms-Icon ms-Icon--alert ms-font-m ms-fontColor-error'></i>");
                      $docName.after("<div class='ms-ListItem-tertiaryText addedError'>" + asyncResult.error.message + "</div>");
                    }
                  });

1 个答案:

答案 0 :(得分:0)

问题出在自签名证书上。