You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VBA邮件代码的Chr(149)前添加空格优化排版?

给Outlook邮件VBA代码中的项目符号添加前置空格

要在Chr(149)项目符号前添加空格优化视觉效果,有两种可靠的实现方式:

方法1:添加HTML非换行空格(推荐)

由于邮件采用HTML格式,普通空格可能被客户端合并为单个,使用HTML的非换行空格 可以确保缩进稳定显示。只需在每个Chr(149)前拼接1-2个 即可:

修改后的项目符号行示例:

& "&nbsp;&nbsp;" & Chr(149) & "<a href="""">Featured Video Design</a> - visitors,  avg. session time." & "<br>" _

方法2:添加普通空格

如果需求简单,也可以直接拼接普通空格字符串:

& "  " & Chr(149) & "<a href="""">Featured Video Design</a> - visitors,  avg. session time." & "<br>" _

完整修改后的VBA代码

Sub EmailHyperlink()
    'updated by Extendoffice 20190815
    Dim xOtl As Object
    Dim xOtlMail As Object
    Dim xStrBody As String
        xStrBody = "Hi [Name]" & "<br>" _
                  & " " & "<br>" _
                  & "we receives monthly traffic of 4,000 visitors looking for video services, and we can help [Agency Name] get more qualified inquiries." & "<br>" _
                  & " " & "<br>" _
                  & "We created a USD -worth of promotion package available for USD  only until August 17, 2022, which includes placements in:" & "<br>" _
                  & " " & "<br>" _
                  & "&nbsp;&nbsp;" & Chr(149) & "<a href="""">Featured Video Design</a> - visitors,  avg. session time." & "<br>" _
                  & "&nbsp;&nbsp;" & Chr(149) & "<a href="" ""> Top Video Production Companies </a> -  visitors,  avg. session time." & "<br>" _
                  & "&nbsp;&nbsp;" & Chr(149) & "<a href="" ""> Top Video Marketing Agencies </a> -  visitors,  avg. session time." & "<br>" _
                  & "&nbsp;&nbsp;" & Chr(149) & "<a href="" ""> 10 Best Video Commercials </a> - visitors,  avg. session time." & "<br>" _
                  & " " & "<br>" _
                  & "Slots are limited and secured on a first-come, first-served basis." & "<br>" _
                  & "<br>" _
                  & "If interested, kindly reply to this email or <a href="" h""> book a meeting </a> with me." & "<br>" _
                  & " " & "<br>" _
                  & " " & "<br>" _
                  & "Thank you."
              
    On Error Resume Next
    Set xOtl = CreateObject("Outlook.Application")
    Set xOtlMail = xOtl.CreateItem(olMailItem)
    With xOtlMail
        .To = "Email Address"
        .CC = " "
        .Subject = "Would [Agency Name] want more exposure for its video services? "
        .HTMLBody = .HTMLBody & xStrBody
        .Display
    End With
    Set xOtl = Nothing
    Set xOtlMail = Nothing
End Sub

说明

  • 使用&nbsp;可以避免Outlook或其他邮件客户端压缩空格,保证项目符号前的缩进效果稳定
  • 可根据视觉需求调整&nbsp;的数量(1个或多个)

内容的提问来源于stack exchange,提问作者Steffan Nikolic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 03:33:31