【发布时间】:2020-11-17 18:51:57
【问题描述】:
我正在尝试使用 Outlook 的 officejs 插件向 outlook 项(收件箱项列表)添加自定义图标。
如果 officejs 无法做到这一点,那么我如何使用 Exchange 服务或任何其他工具或库来实现这一点?
【问题讨论】:
标签: outlook office-js outlook-addin outlook-web-addins outlook-restapi
我正在尝试使用 Outlook 的 officejs 插件向 outlook 项(收件箱项列表)添加自定义图标。
如果 officejs 无法做到这一点,那么我如何使用 Exchange 服务或任何其他工具或库来实现这一点?
【问题讨论】:
标签: outlook office-js outlook-addin outlook-web-addins outlook-restapi
您可以更改图标,但是,您可以选择图标。您需要使用 C# 或 VB.NET(例如 VSTO Outlook-addin)或 VBA。
我找不到您可以使用的图标值列表,但这是旧列表的图像 - 以防链接丢失。
Source of the image and also partly answering your question.
要更改图标,您需要使用MailItem.PropertyAccessor
Const 示例(这些是十六进制值,但您也可以使用 Long)
Const OL_PHONE = &H15D
Const OL_GROUP = &H202
Const OL_NOTE = &H1BD
Const PR_ICON_INDEX As String = "http://schemas.microsoft.com/mapi/proptag/0x10800003"
使用以下辅助方法
'use the Get to see the value of an icon
'prior to this code you would need to get a reference to an Outlook mailitem
Dim res As New Object
GetExtendedPropertyValue(oMailItem, PR_ICON_INDEX, res)
'check the value of res or call Hex(res) to see its hex value
'here you can set the icon eg OL_GROUP etc
SetExtendedPropertyValue(oMailItem, PR_ICON_INDEX, OL_PHONE)
我制作的几个辅助方法
Private Function GetExtendedPropertyValue(ByVal aMailItem As Outlook.MailItem, ByVal aProperty As String, ByRef res As Object) As Boolean
Dim oPropAcc As Outlook.PropertyAccessor = Nothing
Try
oPropAcc = DirectCast(aMailItem.PropertyAccessor, Outlook.PropertyAccessor)
res = oPropAcc.GetProperty(aProperty)
Return True
Catch ex As System.Exception
'Put your own logging here
Finally
If Not oPropAcc Is Nothing Then
Marshal.ReleaseComObject(oPropAcc)
oPropAcc = Nothing
End If
End Try
Return False
End Function
Private Function SetExtendedPropertyValue(ByVal aMailItem As Outlook.MailItem, ByVal aProperty As String, ByVal value As Integer) As Boolean
Dim oPropAcc As Outlook.PropertyAccessor = Nothing
Try
oPropAcc = DirectCast(aMailItem.PropertyAccessor, Outlook.PropertyAccessor)
oPropAcc.SetProperty(aProperty, value)
Return True
Catch ex As System.Exception
'Put your own logging here
Finally
If Not oPropAcc Is Nothing Then
Marshal.ReleaseComObject(oPropAcc)
oPropAcc = Nothing
End If
End Try
Return False
End Function
这三个例子是这样的
可以在此处找到 PR_ICON_INDEX PidTagIconIndex Canonical Property 并注意他们确实说
此属性(如果存在)是对客户端的提示。客户端可能会忽略此属性的值。
然而,情况似乎并非如此。
当然,图标更改不会是永久性的。如果用户转发电子邮件或回复,那么它将被更改。
编辑 顺便说一句,这是找出可能的图标的好方法。创建一个临时文件夹并将垃圾邮件复制到此文件夹 2048 次。然后运行这段代码
Public Sub PrIconIndex()
USE THIS MACRO WITH CARE!
Dim objItems As Items
Dim mail As MailItem
Dim i As Integer
Set objItems = Application.ActiveExplorer.CurrentFolder.Items
For i = 1 To 2048
Set mail = objItems(i)
Call mail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x10800003", i)
mail.Body = CStr(i)
mail.Save
Next
End Sub
以上来自this forum link
【讨论】:
目前不存在向 Outlook 项目添加自定义图标的功能。我们在user-voice page 上跟踪 Outlook 加载项功能请求。请在此处添加您的请求。当我们进行规划过程时,会考虑用户语音的功能请求。
【讨论】: