0
public void updateSignature(ExchangeService exchange, String signature) {
    try {
        FolderId f = new FolderId(WellKnownFolderName.Root);
        UserConfiguration user = UserConfiguration.bind(exchange,
                "OWA.UserOptions", f, UserConfigurationProperties.All);

        if (user.getDictionary().containsKey("signaturetext"))
            user.getDictionary().setElements("signaturetext", signature);
        else
            user.getDictionary().addElement("signaturetext", signature);
        user.update();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

我收到 user.update() 的空指针异常;我可以在设置新签名之前在控制台中打印旧签名,也可以在字典中设置新签名之后打印。但是,我无法永久更新更改。提前致谢 。

4

1 回答 1

0

在其他代码中,它使用的是 root.parentFolderId 而不是 root。也许是这个问题:

附上代码

static void SetSigniture(ExchangeService service) throws Exception {
    Folder Root = Folder.bind(service, WellKnownFolderName.Root);
    UserConfiguration OWAConfig = UserConfiguration.bind(service, "OWA.UserOptions", Root.getParentFolderId(), UserConfigurationProperties.All);
    String hsHtmlSigniture = "<img src='http://www.baidu.com/img/baidu_jgylogo3.gif' />";
    String stTextSig = "Text sig";
    System.out.println(OWAConfig.getDictionary().getElements("timezone"));;
    if (OWAConfig.getDictionary().containsKey("signaturehtml")) {
        OWAConfig.getDictionary().setElements("signaturehtml", new Object());
    } else {
        OWAConfig.getDictionary().addElement("signaturehtml", hsHtmlSigniture);
    }
    if (OWAConfig.getDictionary().containsKey("signaturetext")) {
        OWAConfig.getDictionary().setElements("signaturetext", stTextSig);
    } else {
        OWAConfig.getDictionary().addElement("signaturetext", stTextSig);
    }
    OWAConfig.update();
}
于 2013-02-18T09:53:39.823 回答