我有Exchange 2010,我需要使用Web服务运行一个流程,以与每条新电子邮件一起进入邮箱。该过程基本上将电子邮件添加到内部任务列表中。

我可以为此使用Powershell吗?

在我真的没有任何了解其功能的线索之前,从未使用过Powershell。

如果没有,任何人都可以建议另一种方法,而不是每x秒监视邮箱。真的,我希望基于事件,因此,如果没有新邮件,则没有处理。

欢呼,迈克

有帮助吗?

解决方案

我花了几天的时间来研究这个问题,似乎很难在传入的电子邮件活动中添加自定义代码。如果Exchange认为它正在减慢电子邮件系统,那么许多这样做的方法都将被忽略。 ((http://www.outlookcode.com/article.aspx?id=62)

另一种方法是勾选有效但有些黑客的SMTP事件。为此,您需要编写WScript,然后根据电子邮件到达的事件进行注册。

这是一个示例VB脚本,用于在通过SMTP传递的每封电子邮件中添加随机十六进制。

<SCRIPT LANGUAGE="VBScript">

Sub IEventIsCacheable_IsCacheable()
    'To implement the interface, and return S_OK implicitly
End Sub

Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
    Dim Flds

    randomize()

    set Flds = Msg.Fields
    With Flds
        strSubject = .Item("urn:schemas:httpmail:subject")

        if instr(strSubject, "Ref=") = 0 then
            strSubject = Replace(strSubject, CHR(9), "") & " (Ref=" & hex(replace(timer(), ".", "")) & hex(rnd()) & ")"
            .Item("urn:schemas:httpmail:subject") = strSubject
            .Update
        else
            strSubject = LEFT(strSubject, instr(strSubject, "(Ref=") - 1) & MID(strSubject, instr(instr(strsubject, "(Ref="), strSubject, ")") + 1, Len(strSubject)) & " (Ref=" & hex(replace(timer(), ".", "")) & hex(rnd()) & ")"
            .Item("urn:schemas:httpmail:subject") = strSubject
            .Update
        end if
    End With

    Msg.Datasource.Save

    EventStatus = 0 'Run next sink

End Sub

</SCRIPT>

然后注册脚本运行。

Cscript smtpreg.vbs /add 1 onarrival SMTPAddRef CDO.SS_SMTPOnArrivalSink "mail from=*"
Cscript smtpreg.vbs /setprop 1 onarrival SMTPAddRef Sink ScriptName "C:\ENTERPATH\SMTPRef.vbs"

解开脚本运行以下内容;

cscript smtpreg.vbs /remove 1 onarrival SMTPAddRef

最有弹性的方法似乎是创建一个基于计时器的系统,以每X分钟检查新邮件。

不像我想要的那样光滑,但它会做到。

希望这对他人有所帮助。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top