【发布时间】:2015-03-12 05:45:15
【问题描述】:
有谁知道如何创建包含 URL 书签的 RichText 电子邮件正文?
例如,这是我的代码:
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 = "someone@someone.com"
.Subject = "Email Subject"
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
wdDoc.Range.InsertBefore strBody
'.send
End With
End Sub
非常感谢您的帮助 :) 戴夫
【问题讨论】:
-
你是特别想要RTF还是HTML只要你有链接?
-
嗨,德米特里。我想使用 RTF,但如果它太复杂,那么我将不得不将代码转换为使用 HTMLbody。
-
您仍然可以使用 RTF,但您需要使用 RtfBody 属性或使用 Word 文档对象。你上面的代码有什么问题?
-
我的代码没有任何错误,我只是不知道如何在 strBody 中添加 URL,以便它作为超链接出现生成电子邮件时的电子邮件正文。代码示例会很方便..... :) 注释代码解释了我想要实现的目标。谢谢。
-
@DmitryStreblechenko 这就是我要找的吗?
Object.Hyperlinks.Add(Anchor, Address, SubAddress, ScreenTip, TextToDisplay, Target)Object 是 word 文档对象在哪里?
标签: email excel outlook excel-2013 vba