有谁知道如何创建一个RichText电子邮件正文,该正文中包含URL书签?RichText电子邮件正文中的Excel VBA URL超链接
例如,这里是我的代码:
Sub SendEmailUsingWord()
Dim olApp As Outlook.Application
Dim olEmail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Word.Document
Dim strBody As String
' The body of the message, want to create a hyperlink to (e.g.) http://www.google.com but
' still display HERE.
' In HTML it would be <a href="http://www.google.com">HERE</a>
' But I want to achieve this in a Rich Text email
strBody = "Please click HERE to be fantastic!" & vbNewLine
Set olApp = New Outlook.Application
Set olEmail = olApp.CreateItem(olMailItem)
With olEmail
.BodyFormat = olFormatRichText
.Display
.To = "[email protected]"
.Subject = "Email Subject"
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
wdDoc.Range.InsertBefore strBody
'.send
End With
End Sub
非常感谢您的帮助:) 戴夫
您是否特别想要RTF,或者只要您获得链接,它就可以是HTML? –
嗨德米特里。我想使用RTF,但如果它太复杂,那么我将不得不将代码转换为使用HTMLbody。 – Dave
您仍然可以使用RTF,但您需要使用RtfBody属性或使用Word文档对象。上面的代码出了什么问题? –