用于编辑电子邮件中超链接字体颜色的VBA代码

问题描述 投票:0回答:1

我正在使用Outlook电子邮件模板,在其中找到特定文本,然后将其替换为嵌入式超链接,然后将电子邮件发送出去。但是,发送电子邮件后,超链接的字体颜色默认情况下变为蓝色。

有人可以帮忙编辑以下代码,以便我可以设置某种字体颜色(黑色或白色),并且在电子邮件熄灭时保持不变。

下面的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

提前感谢

excel vba html-email
1个回答
0
投票
strNewText = "<a style='color:#F00;' href='" & strLink & "'>" & strLinkText & "</a>"
© www.soinside.com 2019 - 2024. All rights reserved.