我可以向“outlook"添加自定义图标吗?物品? [英] Can i add custom icon to "outlook" item?
问题描述
我正在尝试使用 Outlook 的 officejs 插件向 outlook 项目(收件箱项目列表)添加自定义图标.
如果 officejs 无法做到这一点,那么我如何使用 Exchange 服务或任何其他工具或库来实现这一目标?
您可以更改图标,但是,您可以选择图标.您需要使用 C# 或 VB.NET(例如 VSTO Outlook-addin)或 VBA.
我找不到您可以使用的图标值列表,但这里有一个旧列表的图像 - 以防链接丢失.
PR_ICON_INDEX PidTagIconIndex 规范属性 可以在这里找到并注意他们确实说
<块引用>此属性(如果存在)是对客户端的提示.客户端可能会忽略此属性的值.
然而,情况似乎并非如此.
当然图标更改不会是永久性的.如果用户转发电子邮件或回复,那么它就会改变.
编辑顺便说一下,这里是找出可能的图标的好方法.制作一个临时文件夹并将垃圾邮件复制到该文件夹中 2048 次.然后运行这段代码
Public Sub PrIconIndex()小心使用这个宏!Dim objItems 作为项目将邮件调暗为 MailItemDim i 作为整数设置 objItems = Application.ActiveExplorer.CurrentFolder.Items对于 i = 1 到 2048设置邮件 = objItems(i)调用 mail.PropertyAccessor.SetProperty(http://schemas.microsoft.com/mapi/proptag/0x10800003", i)mail.Body = CStr(i)邮件.保存下一个结束子
以上来自本论坛链接
I am trying to add a custom icon to outlook items (inbox items list) using officejs addon for outlook.
If this is not possible with officejs then how can I achieve this using Exchange service or with any other tool or library?
You can change the icon, however, you have a choice of icons. You would need to use C# or VB.NET (eg VSTO Outlook-addin) or VBA.
I could not find a list of icon values you can use but here is an image of an old list - in case the link gets lost.
Source of the image and also partly answering your question.
To change the icon you need to use the MailItem.PropertyAccessor
Couple of Examples Const (these are hex values but you can use a Long as well)
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"
Using the below helper methods
'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)
Couple of helper methods I have made
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
These three examples look like this
The PR_ICON_INDEX PidTagIconIndex Canonical Property can be found here and note that they do say
This property, if it exists, is a hint to the client. The client may ignore the value of this property.
However this does not seem to be the case.
Of course the icon change will not be permanent. If the user forwards the emails or replies then it would be changed.
EDIT By the way here is a nice way to find out the possible icons. Make a temp folder and copy a rubbish email into this folder 2048 times. Then run this code
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
The above come from this forum link
这篇关于我可以向“outlook"添加自定义图标吗?物品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!