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 …
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)