我已经写了一些东西,可以快速更改邮件主题,添加发件人首字母,这样我就可以在使用Outlook JIRA插件将其添加到JIRA问题之前点击它。
目前,这是轻度的烦恼,因为它必须打开邮件来更改邮件主题,然后当它返回时,它进入下一个邮件。这就增加了轻度的不便,必须让我移回正确的邮件。
如果能帮助我找出如何让它返回到正确的邮件,我会很感激。也许可以使用MailItem.EntryID,但我不知道如何在关闭时指向它。
Sub EditSubject()
Dim Item As Outlook.MailItem
Dim oInspector As Inspector
Dim strSubject As String
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
Set Item = Application.ActiveExplorer.Selection.Item(1)
Item.Display 'Force the pop-up
Set oInspector = Application.ActiveInspector 'Reassign oInpsector and Item again
Set Item = oInspector.CurrentItem
Else
Set Item = oInspector.CurrentItem
End If
Dim Initials As String
strSubject = Item.Subject
Dim splitName() As String
splitName = Split(Item.SenderName, ",")
Initials = Left$(splitName(1), 2)
Initials = Right$(Initials, 1) + Left$(splitName(0), 1)
Item.Subject = UCase$(Initials) & " - " & strSubject
Item.Close (olSave)
Set Item = Nothing
Set oInspector = Nothing
End Sub
参考文献:[1] 保存带有发件人姓名首字母的电子邮件。
没有必要为一个项目打开一个检查器窗口。你可以改变 Subject
行,而无需在新的检查器窗口中打开一个实际的项目。
Sub EditSubject()
Dim Item As Outlook.MailItem
Dim oInspector As Inspector
Dim strSubject As String
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
Set Item = Application.ActiveExplorer.Selection.Item(1)
Else
Set Item = oInspector.CurrentItem
End If
Dim Initials As String
strSubject = Item.Subject
Dim splitName() As String
splitName = Split(Item.SenderName, ",")
Initials = Left$(splitName(1), 2)
Initials = Right$(Initials, 1) + Left$(splitName(0), 1)
Item.Subject = UCase$(Initials) & " - " & strSubject
Item.Save
Set Item = Nothing
Set oInspector = Nothing
End Sub