【问题标题】:Handle SMTP events using C#使用 C# 处理 SMTP 事件
【发布时间】:2014-09-29 22:08:26
【问题描述】:

当在 smtp 服务器上收到新电子邮件时,我需要触发一个例程。

我找到了有关 Outlook 插件开发的信息,但我认为必须在客户端中安装插件。

好吧,对我来说唯一可行的方法是使用服务在 smtp 服务器上获取NEW_MAIL 环境。

这可能吗?谢谢。

收到新电子邮件后,我必须赶上它。 验证是否有附件。 验证文件名, 如果文件名正确 获取附件并下载到文件服务器...

【问题讨论】:

  • .Net 框架中没有 SMTP 服务器。您需要指定更多详细信息,然后才能回答此问题。展示你尝试过的东西也会是加分项。
  • 我什么都试过了,因为我不知道。实现此功能的唯一方法是使用插件。

标签: c# .net email smtp


【解决方案1】:

我在 OutlookSession 中创建了一个脚本并作为规则应用。 有教程:Apply rule.... has an attachment and run script

Public Sub Drc(emailItem As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim targetFolder As String
    Dim fileName As String
    Dim regxpr As String
    Dim fileType As String
    Dim iFrom As String
    iFrom = "******"
    Dim isubject As String

    isubject = emailItem.Subject
    If emailItem.Sender = iFrom And ValidateFileName(isubject) Then
    For Each objAtt In emailItem.Attachments
        fileType = Split(objAtt.DisplayName, ".")(1)
        targetFolder = "C:\TestCsvDirectory\ToProcess"
        If ValidateFileName(objAtt.DisplayName) And LCase(fileType) = "csv" Then
            objAtt.SaveAsFile (targetFolder & "\" & objAtt.DisplayName)
        End If

    Next
End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    • 1970-01-01
    • 2012-04-20
    相关资源
    最近更新 更多