[英]VBA Code to Edit Font Colour of Hyperlink in Email
我正在使用 Outlook Email 模板,其中我找到一个特定的文本,然后将其替换为嵌入式超链接,然后发送 email。 但是,当发送 email 时,超链接的字体颜色默认为蓝色。
有人可以帮助编辑以下代码,以便我可以设置某种字体颜色(黑色或白色),并且在 email 熄灭时保持不变。
VBA 代码如下
Sub Mail_Merge()
Tme1 = Now()
Application.ScreenUpdating = False
On Error GoTo C:
Dim oApp As Object, oMail As Object
Set oApp = CreateObject("Outlook.Application")
a = Sheet1.Range("B1048576").End(xlUp).Row
For i = 2 To a
Set oMail = oApp.CreateItemFromTemplate(Cells(i, 10))
With oMail
.To = Cells(i, 2)
.Subject = Cells(i, 8)
strfind = "X1X1X1"
strLink = Cells(i, 3)
strLinkText = Cells(i, 9)
strNewText = "<a href=" & Chr(34) & strLink & Chr(34) & ">" & strLinkText & "</a>"
.HTMLBody = Replace(.HTMLBody, strfind, strNewText, 1, 1, vbTextCompare)
.Display
.send
End With
Cells(i, 1) = "Mail sent successfully"
Next i
C:
Application.ScreenUpdating = True
tme2 = Now() - Tme1
Application.StatusBar = Format(tme2, "h:mm:SS")
End Sub
提前致谢
您可以使用内联 CSS:
strNewText = "<a style='color:#F00;' href='" & strLink & "'>" & strLinkText & "</a>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.