为正文中的联系人创建带有@Mention的Outlook电子邮件 [英] Create Outlook email with an @Mention for a contact in the body
本文介绍了为正文中的联系人创建带有@Mention的Outlook电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过Excel VBA生成具有HTML正文的Outlook电子邮件.
I'm generating an Outlook email, which has an HTML body, via Excel VBA.
我想与我所在机构的组织进行联系.例如@Bloggs,乔
I would like to @ a contact in my organisation in the body. e.g. @Bloggs, Joe
Mention
是最近几年添加到Outlook的功能,似乎是HTML链接.如何确保Outlook正确设置此提及
的格式?
Mention
is a functionality added to Outlook in the last few years and it seems it's an HTML link. How do I ensure Outlook formats this mention
correctly?
下面的内容足以使Outlook识别为提及吗?
Would the below suffice for Outlook to recognise this as a mention?
<a href="mailto:Joe.Bloggs@MyOrg.com">
<span style='font-family:"Arial",sans-serif;mso-no-proof:yes;text-decoration:none; text-underline:none'>@Bloggs, Joe</span>
推荐答案
The俩似乎在锚标记的 id
中:
The trick seems to be in the id
of the anchor tag:
- 每个ID必须以
OWAAM
开头(我怀疑它代表提及时提到的Outlook Web Access",因为该功能的来源),然后是32个字符的十六进制值,然后是Z
. - 每个ID在文档中必须是唯一的,但对于提及而言不必是唯一的,因此您只需为每个提及生成一个新的ID.
- Each ID needs to start with
OWAAM
(I suspect it stands for "Outlook Web Access At Mention", as that's where the feature originated), followed by a 32 character hex value, followed byZ
. - Each ID needs to be unique in the document, but doesn't have to be unique for the mention, so you can just generate a new one for each mention.
例如:
<a id="OWAAM954ABFF4E42A42989C2192D3F93BB32DZ"
href="mailto:immo@example.com">Immo Landwerth</a>
此代码对我有用(C#):
This code works for me (C#):
static string GetMentionHtml(string email, string name)
{
var guid = Guid.NewGuid().ToString("N").ToUpper();
var id = $"OWAAM{guid}Z";
return = $"<a id=\"{id}\" href=\"mailto:{email}\">@{name}</a>";
}
如果您在VBA中需要它,
And in case you need it in VBA:
Function GetMentionHtml(email As String, name As String) As String
Dim id As String
Dim html As String
id = "OWAAM" & NewGuid() & "Z"
html = "<a id=""" & id & """ href=""mailto:" & email & """>@" & name & "</a>"
GetMentionHtml = html
End Function
' Sadly there is no "get me a GUID" in VBA, but this is good enough.
' Source: https://www.codegrepper.com/code-examples/vb/excel+vba+generate+guid+uuid
Function NewGuid() As String
Dim k&, h$
NewGuid = Space(36)
For k = 1 To Len(NewGuid)
Randomize
Select Case k
Case 9, 14, 19, 24: h = "-"
Case 15: h = "4"
Case 20: h = Hex(Rnd * 3 + 8)
Case Else: h = Hex(Rnd * 15)
End Select
Mid$(NewGuid, k, 1) = h
Next
NewGuid = Replace(NewGuid, "-", vbNullString, Compare:=vbTextCompare)
End Function
这篇关于为正文中的联系人创建带有@Mention的Outlook电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文