Python ExchangeLib:移动项目的文件夹

时间:2017-05-29 07:45:55

标签: python exchange-server

我在Python中使用ExchangeLib。并希望将我的电子邮件从A文件夹移动到B文件夹。

    # I logined the Exchange Server and took the items as below:
    all_items=account.inbox.all()
    # then wanted to move the folder as below:
    target_folder=account.inbox.get_folder_by_name("TCN")
    recentone = all_items[0]
    # then I wanted to move the folder to "TCN"
    recentone.folder=target_folder;
    recentone.save()

然而,它不起作用,我现在找不到解决方案。 有没有其他方法可以移动项目的文件夹?

提前谢谢。

1 个答案:

答案 0 :(得分:0)

我已将问题发布到github并得到了作者的答案如下:

您无法在文件夹之间移动项目:-)您需要使用move()方法。见https://github.com/ecederstrand/exchangelib#creating-updating-deleting-sending-and-moving

简而言之,以下代码适用于移动文件夹

$ awk -F: -v RS="," '{gsub(/[}]/,"");gsub("\n","")} \
NR==1{printf "%s:%s%s",$2,$3,RT} $1=="\"BPR\"" || $1=="\"SPR\""{printf "%s%s",$0,RT} \
END{printf "\n"}' file
#Output
"name":"James Franco","BPR":6.50,"SPR":6.10