如何使用pywin32重定向Outlook邮件

发布于 2025-01-24 06:49:15 字数 496 浏览 3 评论 0原文

旧消息是初始消息,新消息是我要转发的消息。这就是我尝试的,它似乎不起作用。我不能代表使用帐户发送的发送发送,因为这意味着我需要将原始发件人放在邮箱中。

NewMsg = oldmessage.Forward()
NewMsg.ReplyRecipients.Add(oldmessage.SenderEmailAddress)
NewMsg.Recipients.ResolveAll
NewMsg.Save         
NewMsg.Body = oldmessage.Body
NewMsg.Subject = "Forwarded to Treat: " + oldmessage.Subject
NewMsg.To = [email protected]
NewMsg.Send()

old message is initial message and new message is the message I want to forward. This is what I have tried, it does not seem to work. I cant use send On behalf of an send Using Account as it means I need to have the original sender in my mailbox.

NewMsg = oldmessage.Forward()
NewMsg.ReplyRecipients.Add(oldmessage.SenderEmailAddress)
NewMsg.Recipients.ResolveAll
NewMsg.Save         
NewMsg.Body = oldmessage.Body
NewMsg.Subject = "Forwarded to Treat: " + oldmessage.Subject
NewMsg.To = [email protected]
NewMsg.Send()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事↓在人 2025-01-31 06:49:15

我不能代表发送帐户发送发送,因为这意味着我需要在邮箱中放置原始发件人。

两者之间有区别。

使用帐户功能发送的发送需要在Outlook配置文件中配置另一个帐户,请参见 mailItem.sendusiseAccount 属性返回或设置account对象,该对象表示将要发送mailItem的帐户。代表另一个人发送的发送需要邮箱所有者的权限, mailItem.sentonbehalfofname 属性返回一个字符串,指示邮件邮件的预期发件人的显示名称。

I cant use send On behalf of an send Using Account as it means I need to have the original sender in my mailbox.

There is a difference between the two.

The send using account feature requires another account to be configured in the Outlook profile, see the MailItem.SendUsingAccount property which returns or sets an Account object that represents the account under which the MailItem is to be sent. The send On behalf of another person requires permissions from the mailbox owner, the MailItem.SentOnBehalfOfName property returns a string indicating the display name for the intended sender of the mail message.

心不设防 2025-01-31 06:49:15

您无法保留原始发件人 - Outlook不知道您正在尝试重定向,并且Outlook(和Exchange Server)将阻止您欺骗任意发送者。

在旧的交换世界中,可以创建使用fwd_preserve_sender |的服务器端规则| fwd_do_not_munge_msg flag和op_forward的动作,但我认为如今不使用Outlook使用这些标志,但是扩展的Mapi(仅C ++或Delphi)仍然可以用来像创建一个规则一样那。

编辑:保留发件人的服务器端规则,并且仍然可以使用赎回(我是它的作者):

FWD_PRESERVE_SENDER = 1
FWD_DO_NOT_MUNGE_MSG = 2
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.DefaultStore
set Rules = Store.Rules
set Rule = Rules.Create("Test redirect")

set Action = Rule.Actions.Redirect
set Recip = Action.Recipients.Add("[email protected]")
Recip.Resolve
Action.Enabled = true
Action.Flags = FWD_PRESERVE_SENDER + FWD_DO_NOT_MUNGE_MSG

Rule.ConditionsAsSQL = "Subject like '%test redirect%'"
Rule.Enabled = true
Rule.Save

You cannot keep the original sender - Outlook has no idea that you are trying to redirect, and Outlook (and Exchange server) will prevent you from spoofing an arbitrary sender.

In the old Exchange world, one could create a server-side rule that used FWD_PRESERVE_SENDER | FWD_DO_NOT_MUNGE_MSG flags and the action of OP_FORWARD, but I don't think Outlook uses these flags nowadays, but Extended MAPI (C++ or Delphi only) can probably still be used to create a rule like that.

EDIT: Server-side rules that preserve the sender and the message can still be created using Redemption (I am its author):

FWD_PRESERVE_SENDER = 1
FWD_DO_NOT_MUNGE_MSG = 2
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.DefaultStore
set Rules = Store.Rules
set Rule = Rules.Create("Test redirect")

set Action = Rule.Actions.Redirect
set Recip = Action.Recipients.Add("[email protected]")
Recip.Resolve
Action.Enabled = true
Action.Flags = FWD_PRESERVE_SENDER + FWD_DO_NOT_MUNGE_MSG

Rule.ConditionsAsSQL = "Subject like '%test redirect%'"
Rule.Enabled = true
Rule.Save
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文