【问题标题】:Change outlook subject line更改前景主题行
【发布时间】:2011-07-13 15:10:53
【问题描述】:

如果主题中有特定单词,我如何编写替换主题的 VBA 方法。此代码将在电子邮件正文中找到某个关键字(与主题关键字不同)。然后它将在正文中找到的关键字之后用 13 个字符替换主题行。

以下内容已找到,但未提及如何在电子邮件正文中查找任何内容。而且我没有得到 MAPI 参考。

任何帮助将不胜感激 预先感谢您的任何帮助 瑞克

Sub RewriteSubject(MyMail As MailItem)
  Dim mailId As String
  Dim outlookNS As Outlook.NameSpace
  Dim myMailItem As Outlook.MailItem

  mailId = MyMail.EntryID

  Set outlookNS = Application.GetNamespace("MAPI")
  Set myMailItem = outlookNS .GetItemFromID(mailId)

  ' Do any detection here
  mailItem.Subject = "Dept - " & mailItem.Subject
  myMailItem.Save

  Set mailItem = Nothing
  Set outlookNS = Nothing
End Sub 

【问题讨论】:

    标签: outlook


    【解决方案1】:

    如果是所有新消息,那么您可以使用以下

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    Dim v As Variant
        For Each v In Array("first", "second")
            If InStr(1, Item.Subject, v, vbTextCompare) <> 0 Then
                SearchForAttachWords = True
            End If
        Next
    
        If SearchForAttachWords = True Then
            Item.Subject = "Whatever subject you want"
        End If      
    
    End Sub
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 2015-06-27
      相关资源
      最近更新 更多