我需要构建一个应用程序,该应用程序可以在从交换服务器读取正文(和附件)之后简单地转发电子邮件。 该应用程序内置于云中,并使用python编码,因此我们认为我们将使用exchangelib。
由于云架构,我的目标是转发电子邮件以最大程度地减少出口流量。
从exchangelib source code(从778行开始)中,我找到以下代码:
def create_forward(self, subject, body, to_recipients, cc_recipients=None, bcc_recipients=None):
if not self.account:
raise ValueError('%s must have an account' % self.__class__.__name__)
if not self.id:
raise ValueError('%s must have an ID' % self.__class__.__name__)
return ForwardItem(
account=self.account,
reference_item_id=ReferenceItemId(id=self.id, changekey=self.changekey),
subject=subject,
new_body=body,
to_recipients=to_recipients,
cc_recipients=cc_recipients,
bcc_recipients=bcc_recipients,
)
def forward(self, subject, body, to_recipients, cc_recipients=None, bcc_recipients=None):
self.create_forward(
subject,
body,
to_recipients,
cc_recipients,
bcc_recipients,
).send()
我希望当我使用电子邮件消息(以前下载的)作为自己进行转发时,转发的消息将从服务器而不是从调用方获取有效负载。
希望我的问题很清楚...
预先感谢