小编Dou*_*oug的帖子

Office 365 - EWS 托管 API 2.0 模拟 401 未经授权/503 不可用

private ExchangeService connectToEWS(string email, bool impersonate = false) {
   WebCredentials credentials = new WebCredentials(username, password, domain);
   ExchangeVersion version = (ExchangeVersion)exchangeVersion;
   ExchangeService service = new ExchangeService(version) {
      Credentials = credentials,
      Url = new Uri("https://outlook.office365.com/ews/exchange.asmx")
   };
   if (impersonate) {
      service.HttpHeaders.Add("X-AnchorMailbox", email);
      service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, email);                      service.CookieContainer = new CookieContainer();
   }
   service.Timeout = int.MaxValue;
}
Run Code Online (Sandbox Code Playgroud)

使用上面的代码创建一个 ExchangeSession 并

ExchangeService service = connectToEWS(email, true);
FolderId msgFolderRoot = WellKnownFolderName.MsgFolderRoot;
FolderView view = new FolderView(int.MaxValue);
view.PropertySet = PropertySet.IdOnly;
var result = service.FindFolders(msgFolderRoot, view);
Run Code Online (Sandbox Code Playgroud)

我在 FindFolders …

c# impersonation ews-managed-api office365

5
推荐指数
0
解决办法
794
查看次数

带有结构体的未声明标识符

struct FailedTransaction{
    OrderNodePtr order;
    int failureID;
    struct FailedTransaction* next;
    struct FailedTransaction* tail;
};
typedef struct FailedTransaction* FailedTransactionPtr;

struct SuccessfulTransaction{
    OrderNodePtr order;
    struct SuccessfulTransaction* next;
    struct SuccessfulTransaction* tail;
};
typedef struct SuccessfulTransaction* SuccessfulTransactionPtr;

struct FinalReport{
    FailedTransactionPtr failedTransactions;
    SuccessfulTransactionPtr successfulTransactions;
};

struct FinalReport* report = NULL;
Run Code Online (Sandbox Code Playgroud)

这段代码在 main 之上声明。访问时

report->successfulTransactions
Run Code Online (Sandbox Code Playgroud)

或者

report->failedTransactions
Run Code Online (Sandbox Code Playgroud)

我得到了 FailedTransaction 和SuccessfulTransaction 的未定义标识符。

这是操作报告的代码

if(report == NULL){
    report = malloc(sizeof(struct FinalReport));
    report->failedTransactions = NULL;
    report->successfulTransactions = NULL;
}
if(outcome){
    if(report->successfulTransactions == NULL){
        report->successfulTransactions = malloc(sizeof(SuccessfulTransaction));
        report->successfulTransactions->order = temp;
        report->successfulTransactions->tail …
Run Code Online (Sandbox Code Playgroud)

c struct undefined-reference

1
推荐指数
1
解决办法
4080
查看次数